I need to compare one date range for bookings if they are available eg client sends 21-03-2018 to 25-03-2018 , server returns all Bookings available that are in not inside that range from the database.
List<Booking> findByStarDateBetween(Date start, Date end);
List<Booking> findByEndDateBetween(Date start, Date end);
do i have to go for a custom query?
db table
Booking
int id;
Date startDate;
Date endDate;
You can join the conditions. Hence, your code would be:
List<Booking> results = findByStartDateBeforeAndEndDateAfter(startDate, endDate);
Hope that helps. If not, please leave a comment.