-->
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: Search date range using Date QBC and QBE
PostPosted: Mon Sep 12, 2005 11:11 am 
Newbie

Joined: Mon Sep 12, 2005 11:02 am
Posts: 4
I have a search page that ultimately uses Hibernate's Query by criteria and query by example. However, the search is supposed to allow for a range, a start and end date, if you will.

So my question is two fold. How does one use a Date in QBC/QBE and how does one express a range using a between ala' for Y, y is between x and z or X<=Y<=Z so I can find all Y's that fall between X and Z

Thanks!

David


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 12, 2005 11:21 am 
Pro
Pro

Joined: Fri Sep 02, 2005 4:21 am
Posts: 206
Location: Vienna
Have you tried something like
Quote:
query.add(Expression.between(Y, X, Z));


Erik


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 12, 2005 1:02 pm 
Newbie

Joined: Mon Sep 12, 2005 11:02 am
Posts: 4
ErikFK wrote:
Have you tried something like
Quote:
query.add(Expression.between(Y, X, Z));


Erik


You put me on the right path. Here is what basically worked

Criteria searchCriteria = session.createCriteria(RevisionData.class);

searchCriteria.createCriteria("correspondence").add(Expression.between("dateReceived",
search.getCorrespondenceStartDateRange(),
search.getCorrespondenceEndDateRange()));

where I had a RevisionData class that contains a Correspondence class and I wanted to find all revisions with a correspondece that fell between two dates.

Thanks!

And for anyone with Hibernate in Action, check page 254


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.