Skip to content

Commit

Permalink
feat: 검증 쿼리 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
SHEOMM committed Sep 8, 2024
1 parent 410aa0a commit 66aa2aa
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ public interface CourseRepository extends JpaRepository<Course, Long> {
@Query("SELECT c FROM course c WHERE c.manager.id = :managerId")
List<Course> findAllByManagerId(@Param("managerId")Long managerId);

@Query(nativeQuery = true, value = "SELECT EXISTS(SELECT 1 from course WHERE course.id = :courseId and manager_id = :managerId)")
@Query(nativeQuery = true, value = "SELECT case when EXISTS(SELECT 1 from course WHERE course.id = :courseId and manager_id = :managerId) then 'true' else 'false' end")
boolean isCourseMadeByManagerId(@Param("managerId") Long managerId, @Param("courseId") Long courseId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ public interface SessionRepository extends JpaRepository<Session, Long>{
@Query("UPDATE session s SET s.name= :name WHERE s.id = :sessionId")
void setSessionNameById(@Param("name") String name, @Param("sessionId") Long sessionId);

@Query(nativeQuery = true, value = "SELECT EXISTS "
@Query(nativeQuery = true, value = "SELECT case when EXISTS "
+ "(SELECT 1 FROM course WHERE course.id = "
+ "(SELECT s.course_id FROM session AS s WHERE s.id = :sessionId)"
+ " and course.manager_id = :managerId)")
+ " and course.manager_id = :managerId) then 'true' else 'false' end")
boolean isSessionMadeByManagerId(@Param("managerId") Long managerId, @Param("sessionId") Long sessionId);

}

0 comments on commit 66aa2aa

Please sign in to comment.