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.  [ 3 posts ] 
Author Message
 Post subject: Query question
PostPosted: Thu Mar 31, 2011 7:47 pm 
Newbie

Joined: Sat Jan 24, 2009 1:32 pm
Posts: 9
Howdy,

I'm attempting to write an HQL query where I need to compare two dates. Specifically I need to return all objects whose column lastUpdate is greater than 10 days before now. Could anyone please show me an example of how this is done in HQL?

Regards,

Tim


Top
 Profile  
 
 Post subject: Re: Query question
PostPosted: Fri Apr 01, 2011 10:17 am 
Beginner
Beginner

Joined: Thu Feb 08, 2007 10:40 am
Posts: 46
Code:
Query query = session.createQuery('from MyMappedObject where lastUpdate > :lastUpdate');
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DATE, -10);
query.setParameter('lastUpdate', cal.getTime());
List result = query.list();


Top
 Profile  
 
 Post subject: Re: Query question
PostPosted: Fri Apr 01, 2011 12:36 pm 
Newbie

Joined: Sat Jan 24, 2009 1:32 pm
Posts: 9
That got through. Thanks!

Tim


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.