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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate - Conditions are not applied in Inner Criteria Query" Watch "Hibernate - Conditions are not applied in Inner Criteria Query" New topic
Author

Hibernate - Conditions are not applied in Inner Criteria Query

Saravanan Vijayappan
Ranch Hand

Joined: Jan 02, 2007
Posts: 47
Hi,

Criteria restrictions are not applied in the items of the collections. I have a persistence entity (POJO) Menugroup and it has a collection called catgroups (HashSet, one to many). Catgroup persistence entity (POJO) has another one-to-many collection "dealitems" (HashSet). My criteria query is below:





Mapping file snippet of Menugroup.hbm.xml is below:-


When I run my code, hibernate generates the below 2 sqls and they are displayed in the console

Hibernate generated SQL query-1





Hibernate generated SQL query-2:





The issue issue is, in the result, items in the catgroups collections are not in ascending order and the restriction "published=true" are also not applied on them. I meant to say that below condtions from my criteria query are not applied on catgroups collections.

createCriteria("catgroups").addOrder( Property.forName("name").asc()).
add( Restrictions.eq("published", true) )

The above critieria conditions should be applied on hibernate generated 2nd SQL query but it does not happen. Could any one help me to find out whether I have missed some thing in my criteria query to get the result as I expected or this is a bug in criteria query. ?

Expected result: Items in the catgroups collection should be in order and the condition "published"=true should applied.

I hope, the information i provided above would help to understand what is the problem I face.

Thanks
[ July 07, 2008: Message edited by: Saravanan Vijayappan ]

Cheers,<br />Sarav
Saravanan Vijayappan
Ranch Hand

Joined: Jan 02, 2007
Posts: 47
Any idea please ?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hibernate - Conditions are not applied in Inner Criteria Query
 
Similar Threads
Hibernate Criteria Query not working properly
Question in Hibernate Criteria Query
Hibernate many-to-many error
Hibernate: ArryaList Collection associations are not working
HQL Order By Class is not Sorting