-->
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.  [ 4 posts ] 
Author Message
 Post subject: OR clauses and Criteria searches
PostPosted: Thu Dec 23, 2004 7:38 pm 
Newbie

Joined: Thu Dec 23, 2004 7:26 pm
Posts: 11
I am trying to migrate some reporting queries to Hibernate, and I am unable to find documentation anywhere that details how I might implement an OR clause using Criteria searches. For example, I am trying to do something roughly analogous to the following SQL:

select * from bid as b where b.amount < '100' or (b.amount > '100000' and b.date < '01-JAN-2004')

I apologize if this is in documentation or examples I have missed; every example I am able to find in the HIA object retrieval sections only uses straight AND criterias. I've searched the FAQ and the Criteria JavaDocs, but am still empty-handed. If I've overlooked something, or if there are resources that you can point me to, please let me know.

Todd Farmer


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 23, 2004 7:51 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Look at the Javadoc API for the Expression class, especiall Expression.disjunction() and Expression.conjunction()


Top
 Profile  
 
 Post subject: Thank you!
PostPosted: Thu Dec 23, 2004 8:00 pm 
Newbie

Joined: Thu Dec 23, 2004 7:26 pm
Posts: 11
Thank you for pointing me in the right direction (and so quickly)! This information will really help!

Todd Farmer


Top
 Profile  
 
 Post subject: Found it in HIA
PostPosted: Fri Dec 24, 2004 2:26 pm 
Newbie

Joined: Thu Dec 23, 2004 7:26 pm
Posts: 11
Once I knew what to look for, I did find examples and details of using the Epression.or() and Expression.disjunction() methods on page 256. It's even in the index (under Logical Operators)!

Thanks again for pointing me in the right direction; and thanks to the HIA authors for a comprehensive look at Hibernate.

Todd Farmer


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.