-->
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: simply problem with queries on dates!! probably very simple!
PostPosted: Fri Jan 14, 2005 9:47 am 
Newbie

Joined: Fri Oct 08, 2004 9:26 am
Posts: 17
i have a class of objects which have a java date object as on of thier properties.

how would I create a HQL query which did something along these lines:

"from photos where takendate >= upperbound and <= lowerbound"

the question i guess is what type the upperbound and lowerbound should be. i tried creating java date objects and then using thier .toString() method but that failed!

help appreciated greatly!!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 14, 2005 11:01 pm 
Expert
Expert

Joined: Fri Nov 07, 2003 4:24 am
Posts: 315
Location: Cape Town, South Africa
Use:
Code:
Query query = session.createQuery(from Photo p where p.takendate >= :lowerDate and p.takenDate <= :upperDate);
query.setDate("lowerDate", yourLowerDate);
query.setDate("upperDate", yourUpperDate);


Note that yourUpperDate and yourLowerDate are java.util.Date objects.


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.