• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Hibernate - Conditions are not applied in Inner Criteria Query

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Saravanan Vijayappan
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any idea please ?
 
Or we might never have existed at all. Freaky. So we should cherish everything. Even this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic