Hibernate version: 2.0.3
MySQL version: 4.0.13-nt
Following is the hibernate query that I have:
Code:
query = session.createQuery("select requests from Request requests, Log log where log.request = requests and requests.requestType = :type and requests.userId = :userId and log.logTime.time between :startdate and :enddate and log.status = :status");
Following is the structure of the database table it uses:
Code:
cnet.Log
----------------------------
Field Type
id varchar(32)
contentId varchar(32)
logtime [b]datetime[/b]
requestId varchar(32)
status int(11)
The issue I have is that I set the
startdate and
enddate using java.util.Date, but I have zero Request objects returned from the query execution.
When I run the equivalent SQL query with the dates in the format '2004-03-15 00:00:00' and '2004-03-15 23:59:59', I get the desired values.
Could someone please throw some light on what the issue here might be. We are facing problems in manipulating the Date object for the Hibernate query so as to get the desired execution using the between clause.
Thanks,
/SAmith