-->
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: Criteria don't support Date?
PostPosted: Wed Feb 16, 2005 3:39 am 
Senior
Senior

Joined: Wed Dec 17, 2003 4:24 am
Posts: 188
Hi everyone:

I want to know if Hibernate Criteria API can be used with java.util.Date. For example, could I use it in the following code?

Code:
List list= session.createCriteria(Person.class)
     .add( Expression.gt("birthday", myBean.getBirthday()) )
     .add( Expression.ge( "createDate", "1982-2-7" ) )
     .addOrder( Order.asc("createDate") )
     .list();


It seems don't work in Hibernate 2.1.6. I don't want to use HQL. If I use Criteria API,how to do it? I mean how to search by Date using Criteria? Thks!

_________________
You are not alone...


Top
 Profile  
 
 Post subject: Mistake
PostPosted: Wed Feb 16, 2005 4:16 am 
Senior
Senior

Joined: Wed Dec 17, 2003 4:24 am
Posts: 188
Oh, sorry for my mistake, it is numberFormat error and Criteria can search by Date. The following code can work well.

Code:
Date d=new Date();
      List list=s.createCriteria(Person.class).add(Expression.ge("create_date",d)).list();


It 's great and convinent API :-)

_________________
You are not alone...


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.