Search code examples
spring-boothibernatespring-data-jparepository

Spring Boot Query on Date field without time


I have an entity with a Date field with type of java.util.Date, and this field in oracle db has the timestamp type.

the problem is that when i use the repository to find by given specs, it returns nothing for the given date.

It only happens when i want the exact equal date. it works fine with greaterThen and lessThen and that's because the time of the saved records are different.

how could I ignore the time of records and fetch them only for the given date?

Thanks a million


Solution

  • because the data was saved with the time best way was to do it with between condition from 00:00 to 23:59 in that day. special thanks to this link :

    Spring Data Querying DateTime with only Date

    but i solved the problem by creating a view from that table and removing the time from the date in oracle.