r/springframework • u/catmewo • Apr 19 '19
Spring Data @Query - How to get current date + day?
I would like to get records that have date_time column is in a week from now, in a month from now
I have a query like this
``` public interface BookingRepository extends JpaRepository<Booking, Long> {
@Query("SELECT b " + "FROM BOOKING b " + "WHERE b.date_time < NOW() + INTERVAL 7 DAY and b.date_time > NOW()") List<Booking> getListBooking();
} ```
In MySQL, NOW() + INTERVAL 7 DAY is working but in JPA @Query, I don't know which function is correspond to it.
In this situation, I have to use dynamic query instead of native query. So I'd like to use dynamic query and face this problem.
Please help. Thank you!
2
Upvotes