This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Object Relational Mapping and the fly likes adding or in criteria query Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "adding or in criteria query" Watch "adding or in criteria query" New topic
Author

adding or in criteria query

Ankit Chandrawat
Ranch Hand

Joined: Jan 03, 2008
Posts: 87
Hi,

I want to write a criteria query in Hibernate using which i can select dates of a particular month for multiple years(four years in total).

For example I want it fetch the rows for whose date should be
between
(1st april 2011 and 1st May 2011) or the date should be between
(1st april 2010 and 1st May 2010) or the date should be between
(1st april 2009 and 1st May 2009) or the date should be between
(1st april 2008 and 1st May 2008)

TIA,
Ankit
Anantha Sharma
Ranch Hand

Joined: Sep 01, 2010
Posts: 43

Hi Ankit,

you can use the Restrictions class in hibernate to achive this....


Here is a sample.



hope this helps.
Ankit Chandrawat
Ranch Hand

Joined: Jan 03, 2008
Posts: 87
Hi Anantha,

It worked really well. You saved my day. Thanks a lot.

Thanks and Regards,
Ankit Chandrawat
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: adding or in criteria query