-->
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.  [ 2 posts ] 
Author Message
 Post subject: HQL on the second side of a many-to-many mapping
PostPosted: Sun Aug 20, 2006 2:28 pm 
Newbie

Joined: Tue Mar 07, 2006 4:54 am
Posts: 6
Hi,

I have a many-to-many mapping with the following classes/ tables:
Car
Part
CarPart (implementing the many-to-many)

I would like to make the following query to find all cars that have the car part='Door'.

How would I do that? From Car AS car WHERE car.CarPart.Part='Door' ?

Thanks,

Assaf


Top
 Profile  
 
 Post subject:
PostPosted: Sun Aug 20, 2006 6:00 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
If you have mapped the many-to-many using the normal colleciton technique (using the many-to-many element), then ignore the CarPart table. It's hidden by hibernate. The query would be "from Car c where c.Parts.Name = 'door'", assuming that you've mapped "Parts" as the name of the collection containing a car's parts (i.e. you have a method Set<Part> getParts();).

_________________
Code tags are your friend. Know them and use them.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.