Answer the question
In order to leave comments, you need to log in
How to get data by date in jpa repository?
I need to get data by date. For example, all data for 2020-02-19.
Wrote a request
List<Client> findByUserIdAndRegistrationDate(UUID id, Date date);
Answer the question
In order to leave comments, you need to log in
1. To search by date for all users (and in the question I did not see that a selection was needed for one user), UUID is not needed.
2. Yes
Maybe due to the fact that I send 2020-02-19 and in the database 2020-02-19 23:36:00 and they are not equalso it is, the date in this case is supplemented with 00:00:00, that is, the search occurs at the beginning of the day.
findAllByRegistrationDateBetween(дата_начала_периода, дата_окончания_периода)
findAllByUserIdAndRegistrationDateBetween(user_id, дата_начала_периода, дата_окончания_периода)
List<Client> findByUserIdAndRegistrationDate(UUID id, Date date);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question