|
12 | 12 | @Repository |
13 | 13 | public interface StudentExamScoreRepository extends JpaRepository<StudentExamScore, Long> { |
14 | 14 |
|
15 | | - Optional<StudentExamScore> findByExamAndStudentId(Exam exam, Long studentId); |
| 15 | + @Query("SELECT ses FROM StudentExamScore ses " + |
| 16 | + "JOIN ses.exam e " + |
| 17 | + "JOIN e.mainClass mc " + |
| 18 | + "JOIN mc.academy a " + |
| 19 | + "WHERE a.id = :academyId " + |
| 20 | + "AND e = :exam " + |
| 21 | + "AND ses.student.id = :studentId") |
| 22 | + Optional<StudentExamScore> findByExamAndStudentIdAndAcademyId(@Param("academyId") Long academyId, |
| 23 | + @Param("exam") Exam exam, |
| 24 | + @Param("studentId") Long studentId); |
| 25 | + |
16 | 26 |
|
17 | 27 | Optional<StudentExamScore> findByStudentAndExamId(Student student, Long examId); |
18 | 28 |
|
19 | | - List<StudentExamScore> findByExam(Exam exam); |
20 | | - @Query("SELECT s FROM StudentExamScore s WHERE s.exam = :exam") |
21 | | - List<StudentExamScore> findAllByExam(@Param("exam") Exam exam); |
| 29 | + @Query("SELECT ses FROM StudentExamScore ses " + |
| 30 | + "JOIN ses.exam e " + |
| 31 | + "JOIN e.mainClass mc " + |
| 32 | + "JOIN mc.academy a " + |
| 33 | + "WHERE a.id = :academyId " + |
| 34 | + "AND ses.exam = :exam") |
| 35 | + List<StudentExamScore> findByAcademyIdAndExam(@Param("academyId") Long academyId, |
| 36 | + @Param("exam") Exam exam); |
| 37 | + |
| 38 | + @Query("SELECT ses FROM StudentExamScore ses " + |
| 39 | + "JOIN ses.exam e " + |
| 40 | + "JOIN e.mainClass mc " + |
| 41 | + "JOIN mc.academy a " + |
| 42 | + "WHERE a.id = :academyId " + |
| 43 | + "AND ses.exam = :exam") |
| 44 | + List<StudentExamScore> findAllByAcademyIdAndExam(@Param("academyId") Long academyId,@Param("exam") Exam exam); |
22 | 45 |
|
23 | 46 |
|
24 | 47 | List<StudentExamScore> findByScoreReport(ScoreReport scoreReport); |
|
0 commit comments