-->
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.  [ 3 posts ] 
Author Message
 Post subject: Is it possible to run this with the Criteria API ?
PostPosted: Fri Oct 21, 2005 11:25 am 
Newbie

Joined: Wed Oct 19, 2005 6:57 am
Posts: 4
Location: Toulouse, FRANCE
Hi,
while porting our application from JDO to Hibernate, we're wondering whether the Criteria api would be powerful enough to allow generic querying involving objects not navigable from the root class (the HQL api can do this and we'll stick with it if it's the only way).
For instance : If we have a class Cats and another, called Paternity, with a collection of Cats as "children" and a Cats instance as "parent" to represent who is the parent of kittens (The model is a legacy from the old developments so we have to stick with it).
If I'm looking for all Cats whose the grand parent is named 'kitty', we could write it in HQL (or so we think) as :
Code:
select catChild
   from Cats catChild, Paternity paternity1, Paternity paternity2
  where paternity1.parent.name = 'kitty'
    and paternity1.children.contains(paternity2.parent)
    and paternity2.children.contains(catChild)

When trying with the Criteria api, no matter which root class we're trying with, there is something which isn't navigable FROM the root class (but which is navigable TO). It looks like we can't introduce extra class in the from clause and should stick with only one there. Is it true or does the Criteria api allow to do this kind of request and if so, how ?
Thanks in advance

Olivier


Top
 Profile  
 
 Post subject: Re: Is it possible to run this with the Criteria API ?
PostPosted: Mon Oct 24, 2005 1:14 pm 
Newbie

Joined: Thu Jul 07, 2005 8:10 am
Posts: 6
Location: St. Louis, MO
ojolly wrote:
Hi,
When trying with the Criteria api, no matter which root class we're trying with, there is something which isn't navigable FROM the root class (but which is navigable TO). It looks like we can't introduce extra class in the from clause and should stick with only one there. Is it true or does the Criteria api allow to do this kind of request and if so, how ?
Thanks in advance

Olivier


Use a nested call to createCriteria() to traverse an association. See the very first example under section 16.4 of the Hibernate 3.0.5 user manual.


Top
 Profile  
 
 Post subject: Re: Is it possible to run this with the Criteria API ?
PostPosted: Mon Oct 24, 2005 2:09 pm 
Newbie

Joined: Wed Oct 19, 2005 6:57 am
Posts: 4
Location: Toulouse, FRANCE
burke_e wrote:
Use a nested call to createCriteria() to traverse an association. See the very first example under section 16.4 of the Hibernate 3.0.5 user manual.


Thank you but in fact the two tables are not related via the business model.
In fact, it happens that this problem is known and is not yet solved.


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