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: SubQuery an Criteria problem whith association
PostPosted: Sun Oct 08, 2006 7:42 pm 
Newbie

Joined: Sun Oct 08, 2006 7:17 pm
Posts: 2
Hello,

Imagine you have two tables
A table Parent and a table Child

How can I have All the parents they have a child who's name is Jhon ant an other child who's name is Jack ?

Parent and child are mapped whith one-to-many association.

I tried
.createCriteria(Parent.class).
.createCriteria("ChildList")
.add(Restriction.conjonction()
.add(Restrictions.eq("name","Jhon")
.add(Restrictions.eq("name","Jack")
)

But it don't work.

Thank you for your help

Tom


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 08, 2006 9:36 pm 
Beginner
Beginner

Joined: Tue Sep 26, 2006 11:46 pm
Posts: 33
In HQL I believe you can do something like:

Code:
SELECT p
FROM Parent as p
INNER JOIN p.children as child1
INNER JOIN p.children as child2
WHERE child1.name = 'John'
AND child2.name = 'Jack'


Don't know about criteria I'm afraid.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 09, 2006 6:00 pm 
Newbie

Joined: Sun Oct 08, 2006 7:17 pm
Posts: 2
Thank you, but I really need criteria,

No Idea?


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.