refactor: MovieTimeRepository - findValidMovieTimes 네이티브 쿼리 -> JPQL 변경
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.ticketing.server.movie.domain.repository;
|
||||
|
||||
import com.ticketing.server.movie.domain.Movie;
|
||||
import com.ticketing.server.movie.domain.MovieTime;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
@@ -10,12 +11,11 @@ import org.springframework.stereotype.Repository;
|
||||
@Repository
|
||||
public interface MovieTimeRepository extends JpaRepository<MovieTime, Long> {
|
||||
|
||||
@Query(value = "SELECT * "
|
||||
+ "FROM movie_time "
|
||||
+ "WHERE movie_id = :movieId "
|
||||
+ "AND start_at "
|
||||
+ "BETWEEN date_format(start_at, :startOfDay) "
|
||||
+ "AND date_format(start_at, :endOfDay)", nativeQuery = true)
|
||||
List<MovieTime> findValidMovieTimes(long movieId, LocalDateTime startOfDay, LocalDateTime endOfDay);
|
||||
@Query(value = "SELECT mt "
|
||||
+ "FROM MovieTime mt "
|
||||
+ "JOIN FETCH mt.movie "
|
||||
+ "WHERE mt.movie = :movie "
|
||||
+ "AND mt.startAt BETWEEN :startOfDay AND :endOfDay ")
|
||||
List<MovieTime> findValidMovieTimes(Movie movie, LocalDateTime startOfDay, LocalDateTime endOfDay);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user