Interface AssignmentRepository
- All Superinterfaces:
org.springframework.data.repository.CrudRepository<Assignment,,Long> org.springframework.data.jpa.repository.JpaRepository<Assignment,,Long> org.springframework.data.repository.ListCrudRepository<Assignment,,Long> org.springframework.data.repository.ListPagingAndSortingRepository<Assignment,,Long> org.springframework.data.repository.PagingAndSortingRepository<Assignment,,Long> org.springframework.data.repository.query.QueryByExampleExecutor<Assignment>,org.springframework.data.repository.Repository<Assignment,Long>
public interface AssignmentRepository
extends org.springframework.data.jpa.repository.JpaRepository<Assignment,Long>
Repository for persisting and querying
Assignment records.-
Method Summary
Modifier and TypeMethodDescriptionfindAllByCourse(Course course) Finds all assignments associated with a course.findByCourseAndExternalId(Course course, String externalId) Finds an assignment by course and external LMS identifier.findByIdAndUser(Long id, User user) Finds a single assignment by ID scoped to the given user.findByUser(User user) Finds all assignments belonging to courses owned by 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
-
findByUser
@Query("SELECT a FROM Assignment a JOIN a.course c JOIN c.integration i WHERE i.user = :user") List<Assignment> findByUser(@Param("user") User user) Finds all assignments belonging to courses owned by the given user.- Parameters:
user- the owning user- Returns:
- assignments accessible to the user
-
findByIdAndUser
@Query("SELECT a FROM Assignment a JOIN a.course c JOIN c.integration i WHERE i.user = :user AND a.id = :id") Optional<Assignment> findByIdAndUser(@Param("id") Long id, @Param("user") User user) Finds a single assignment by ID scoped to the given user.- Parameters:
id- the assignment IDuser- the owning user- Returns:
- an optional containing the assignment, if found and owned by the user
-
findAllByCourse
Finds all assignments associated with a course.- Parameters:
course- the course to search within- Returns:
- assignments belonging to the course
-
findByCourseAndExternalId
Finds an assignment by course and external LMS identifier.- Parameters:
course- the owning courseexternalId- the external assignment identifier- Returns:
- an optional containing the matching assignment, if found
-