wood burning stoves 2.0*
The moose likes Object Relational Mapping and the fly likes Query Criteria in Hibernate Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Query Criteria in Hibernate" Watch "Query Criteria in Hibernate" New topic
Author

Query Criteria in Hibernate

Mayur Shinde
Greenhorn

Joined: Feb 15, 2012
Posts: 18
Hi,

I am having multiple texbox for different parameters of a POJO and through this values I have to execute query. If all parameters are explicitly submitted by user then there is no problem in query, since all criteria are there.
If user din't fill up all textbox what will be the query for checking null values and then only allowing it to be a part of criteria. I am using hibernate as ORM Tool.

Regards,
Mayur Shinde
Ganesh Shirsat
Ranch Hand

Joined: Jan 10, 2010
Posts: 33

Hi Mayur,

1. check how many parameter are exist.
2. According to parameter create different criterion object and add in DetachedCriteria.

You can use DetachedCriteria.

Step 1


Ste 2

Mayur Shinde
Greenhorn

Joined: Feb 15, 2012
Posts: 18
Thanks Ganesh,

It solved my problem that how i will be creating my hibernate query(parameter which i will be passing). But now i am facing a new problem that i am having two class A & B, with relation one to many so A is having Set<A>, now i want to query db with the help of Set<A> like where Set<A>=?, So what will be query in hql.

Regards,
Mayur Shinde
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Query Criteria in Hibernate