-->
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 to query Dates with criteria?
PostPosted: Fri May 12, 2006 2:13 pm 
Beginner
Beginner

Joined: Wed Apr 27, 2005 8:27 am
Posts: 27
Hi everyone,

which static methods in Restrictions class can I use to query dates with criteria?
The methods ge, gt, lt, le and between did not work.
Can anybody give me a hint?

thanks, Guilherme


Top
 Profile  
 
 Post subject: Re: How to query Dates with criteria?
PostPosted: Fri May 12, 2006 6:42 pm 
Newbie

Joined: Fri May 12, 2006 10:37 am
Posts: 2
Guilherme_82 wrote:
Hi everyone,

which static methods in Restrictions class can I use to query dates with criteria?
The methods ge, gt, lt, le and between did not work.
Can anybody give me a hint?

thanks, Guilherme


If your DB columns are typed correctly and you're using java.util.Date, that should work. See here:

http://www.jroller.com/page/wakaleo/?an ... iteria_api

They use Dates to demonstrate using the Criteria API:

Code:
Criteria criteria = session.createCriteria(Sale.class);
    if (startDate != null) {
        criteria.add(Expression.ge("date",startDate);
    }
    if (endDate != null) {
        criteria.add(Expression.le("date",endDate);
    }
    List results = criteria.list();


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.