Class SubjectRepositoryImpl
java.lang.Object
org.example.crmedu.infrastructure.repository.subject.SubjectRepositoryImpl
- All Implemented Interfaces:
SubjectRepository
Implementation of the
SubjectRepository
interface using JPA. Provides methods for managing Subject
entities in the database.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Deletes a subject by its unique identifier.boolean
existsByNameAndOrganizationId
(Subject subject) Checks whether a subject with the same name that belongs to certain organization already exists.findAll
(int pageNumber, int pageSize) Retrieves a paginated list of subjects.Retrieves a subject by its unique identifierSaves a new subject or updates an existing one.void
Updates an existing subject.
-
Constructor Details
-
SubjectRepositoryImpl
public SubjectRepositoryImpl()
-
-
Method Details
-
save
Description copied from interface:SubjectRepository
Saves a new subject or updates an existing one.- Specified by:
save
in interfaceSubjectRepository
- Parameters:
subject
- the subject to save- Returns:
- the saved
Subject
entity
-
findById
Description copied from interface:SubjectRepository
Retrieves a subject by its unique identifier- Specified by:
findById
in interfaceSubjectRepository
- Parameters:
id
- the unique identifier of the subject- Returns:
- an
Optional
containing the subject if found, otherwise empty
-
existsByNameAndOrganizationId
Description copied from interface:SubjectRepository
Checks whether a subject with the same name that belongs to certain organization already exists.- Specified by:
existsByNameAndOrganizationId
in interfaceSubjectRepository
- Parameters:
subject
- the subject to check- Returns:
true
if a subject with the same name exists, otherwisefalse
-
findAll
Description copied from interface:SubjectRepository
Retrieves a paginated list of subjects.- Specified by:
findAll
in interfaceSubjectRepository
- Parameters:
pageNumber
- the page number (starting from 0)pageSize
- the number of subjects per page- Returns:
- a
Page
containing the requested subjects
-
update
Description copied from interface:SubjectRepository
Updates an existing subject.- Specified by:
update
in interfaceSubjectRepository
- Parameters:
subject
- the subject entity with updated information
-
delete
Description copied from interface:SubjectRepository
Deletes a subject by its unique identifier.- Specified by:
delete
in interfaceSubjectRepository
- Parameters:
id
- the unique identifier of the subject to delete
-