-->
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: How does hibernate handle dates
PostPosted: Mon Jul 03, 2006 10:31 am 
Newbie

Joined: Wed Sep 14, 2005 4:57 am
Posts: 10
Hi

I am using hibernate and have my mapping correct with the db. I would like to perform a query using a date value. In what format must the date be my query looks as follows :
" query.append("from com.directory.AuditEntry ae where ae.cretedOn = '2006-06-03 '");

must the value be equal to an object instead. It would also help if you could just explain how hibernate handles dates in query's

--
Regards,

Ryan Meder


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 03, 2006 12:58 pm 
Newbie

Joined: Mon Jul 03, 2006 5:16 am
Posts: 5
My advise is to use the setDate method of Query:

Code:
String s = "from com.directory.AuditEntry ae where ae.cretedOn = :filterDate";
Query q = session.createQuery(s);
//Date initialization
Date myDate = new Date();
...
q.setDate("filterDate", myDate);


The same with other operators: greater than, less than, between, etc.


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.