1

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!

1 Answer 1

2

there is no date_add in JPA so you would have few options:

personally i would go with query parametrization as it is easier to test and maintain in the long-run.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.