Interface CourseRepository
- All Superinterfaces:
org.springframework.data.repository.CrudRepository<Course,,Long> org.springframework.data.jpa.repository.JpaRepository<Course,,Long> org.springframework.data.repository.ListCrudRepository<Course,,Long> org.springframework.data.repository.ListPagingAndSortingRepository<Course,,Long> org.springframework.data.repository.PagingAndSortingRepository<Course,,Long> org.springframework.data.repository.query.QueryByExampleExecutor<Course>,org.springframework.data.repository.Repository<Course,Long>
public interface CourseRepository
extends org.springframework.data.jpa.repository.JpaRepository<Course,Long>
Repository for persisting and querying
Course records.-
Method Summary
Modifier and TypeMethodDescriptionfindAllByIntegration(Integration integration) Finds all courses linked to an integration.findAllByUser(User user) Finds all courses belonging to the given user.findByIntegrationAndExternalCourseId(Integration integration, String externalCourseId) Finds a course by integration and external LMS course identifier.findByUserAndExternalId(User user, String id) Finds a course by external identifier scoped to the given user.findByUserAndId(User user, Long id) Finds a course by ID scoped to the given user.Methods inherited from interface org.springframework.data.repository.CrudRepository
count, delete, deleteAll, deleteAll, deleteAllById, deleteById, existsById, findById, saveMethods inherited from interface org.springframework.data.jpa.repository.JpaRepository
deleteAllByIdInBatch, deleteAllInBatch, deleteAllInBatch, deleteInBatch, findAll, findAll, flush, getById, getOne, getReferenceById, saveAllAndFlush, saveAndFlushMethods inherited from interface org.springframework.data.repository.ListCrudRepository
findAll, findAllById, saveAllMethods inherited from interface org.springframework.data.repository.ListPagingAndSortingRepository
findAllMethods inherited from interface org.springframework.data.repository.PagingAndSortingRepository
findAllMethods inherited from interface org.springframework.data.repository.query.QueryByExampleExecutor
count, exists, findAll, findBy, findOne
-
Method Details
-
findAllByUser
@Query("SELECT c FROM Course c JOIN c.integration i WHERE i.user = :user") List<Course> findAllByUser(@Param("user") User user) Finds all courses belonging to the given user.- Parameters:
user- the owning user- Returns:
- courses accessible to the user
-
findByUserAndId
@Query("SELECT c FROM Course c JOIN c.integration i WHERE c.id = :id AND i.user = :user") Optional<Course> findByUserAndId(@Param("user") User user, @Param("id") Long id) Finds a course by ID scoped to the given user.- Parameters:
user- the owning userid- the course ID- Returns:
- an optional containing the course, if found and owned by the user
-
findByUserAndExternalId
@Query("SELECT c FROM Course c JOIN c.integration i WHERE c.externalCourseId = :external_id AND i.user = :user") Optional<Course> findByUserAndExternalId(@Param("user") User user, @Param("external_id") String id) Finds a course by external identifier scoped to the given user.- Parameters:
user- the owning userid- the external course identifier- Returns:
- an optional containing the course, if found
-
findAllByIntegration
Finds all courses linked to an integration.- Parameters:
integration- the integration to search within- Returns:
- courses associated with the integration
-
findByIntegrationAndExternalCourseId
Optional<Course> findByIntegrationAndExternalCourseId(Integration integration, String externalCourseId) Finds a course by integration and external LMS course identifier.- Parameters:
integration- the owning integrationexternalCourseId- the external course identifier- Returns:
- an optional containing the matching course, if found
-