-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: HQL date comparison issue
PostPosted: Wed Jul 25, 2007 5:18 pm 
Newbie

Joined: Fri Apr 27, 2007 6:15 pm
Posts: 1
Location: Canada
Hibernate version: 3.2

I find that HQL doesn't return anything for a query like

Code:
select distinct item from OrderItem as item, Order as order left join fetch item.order as order where order.orderDate >= :startDate  and order.orderDate <= :endDate 


where startDate and endDate are equal.
I had to adjust it so that end date is slightly ahead (in my case the least count is a day). Its almost like the <= operator is working like the <.

Anyone seen this happen before?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 25, 2007 5:50 pm 
Expert
Expert

Joined: Fri Jul 13, 2007 8:18 am
Posts: 370
Location: london
I suspect you're storing the time as well as the date in the orderDate field. In this case, when startDate and endDate are equal, you'll only select orders that match to the exact _second_.

I'm guessing you want to select orders for a particular day. To do this, the _time_ of start date should be 00:00:00 i.e. midnight and the _time_ of end date 23:59:59

Mike


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.