Class SubjectRepositoryImpl

java.lang.Object
org.example.crmedu.infrastructure.repository.subject.SubjectRepositoryImpl
All Implemented Interfaces:
SubjectRepository

@Component public class SubjectRepositoryImpl extends Object implements SubjectRepository
Implementation of the SubjectRepository interface using JPA. Provides methods for managing Subject entities in the database.
  • Constructor Details

    • SubjectRepositoryImpl

      public SubjectRepositoryImpl()
  • Method Details

    • save

      public Subject save(Subject subject)
      Description copied from interface: SubjectRepository
      Saves a new subject or updates an existing one.
      Specified by:
      save in interface SubjectRepository
      Parameters:
      subject - the subject to save
      Returns:
      the saved Subject entity
    • findById

      public Optional<Subject> findById(Long id)
      Description copied from interface: SubjectRepository
      Retrieves a subject by its unique identifier
      Specified by:
      findById in interface SubjectRepository
      Parameters:
      id - the unique identifier of the subject
      Returns:
      an Optional containing the subject if found, otherwise empty
    • existsByNameAndOrganizationId

      public boolean existsByNameAndOrganizationId(Subject subject)
      Description copied from interface: SubjectRepository
      Checks whether a subject with the same name that belongs to certain organization already exists.
      Specified by:
      existsByNameAndOrganizationId in interface SubjectRepository
      Parameters:
      subject - the subject to check
      Returns:
      true if a subject with the same name exists, otherwise false
    • findAll

      public Page<Subject> findAll(int pageNumber, int pageSize)
      Description copied from interface: SubjectRepository
      Retrieves a paginated list of subjects.
      Specified by:
      findAll in interface SubjectRepository
      Parameters:
      pageNumber - the page number (starting from 0)
      pageSize - the number of subjects per page
      Returns:
      a Page containing the requested subjects
    • update

      public void update(Subject subject)
      Description copied from interface: SubjectRepository
      Updates an existing subject.
      Specified by:
      update in interface SubjectRepository
      Parameters:
      subject - the subject entity with updated information
    • delete

      public void delete(Long id)
      Description copied from interface: SubjectRepository
      Deletes a subject by its unique identifier.
      Specified by:
      delete in interface SubjectRepository
      Parameters:
      id - the unique identifier of the subject to delete