Reputation: 2335
I have a JPA mapped "event" object that includes a timestamp column. I am trying to select all events that occurred on a specific date. To do this I need to ignore the time component of the timestamp. I am not sure that this is possible using non database specific functions? Something like this fails to select:
@Query("SELECT r FROM BioChemRequest r WHERE r.pasId = :pasid AND r.observationDate BETWEEN :startDate AND :startDate")
public List <BioChemRequest> find(@Param("pasid") String pasid , @Param("startDate") Date startDate);
Upvotes: 0
Views: 1144
Reputation: 751
try the following
@Query("SELECT r FROM BioChemRequest r WHERE r.pasId = :pasid AND r.observationDate BETWEEN :startDate AND :endDate")
public List <BioChemRequest> find(@Param("pasid") String pasid , @Param("startDate") Calendar startDate, @Param("endDate") Calendar endDate);
where startDate is a calendar with hour 00:00:00 000
and endDate is a calendar with hour 23:59:59 999
Upvotes: 1