-->
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.  [ 6 posts ] 
Author Message
 Post subject: HQL on the second side of a many-to-many mapping
PostPosted: Sun Aug 20, 2006 2:27 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: Mon Aug 21, 2006 2:45 am 
Regular
Regular

Joined: Tue Dec 14, 2004 5:21 am
Posts: 104
Location: india
hi assaf,
i wonder why u want to have a many to many relationship between a car and its parts . i would rather suggest a one-to-many relationship to car-parts .

then u can query like select p.car from parts p where p.partname='something'

correct me if im wrong

_________________
sHeRiN
thanks for your ratings ...... :)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 21, 2006 3:02 am 
Expert
Expert

Joined: Thu Sep 22, 2005 10:29 am
Posts: 285
Location: Almassera/Valencia/Spain/EU/Earth/Solar system/Milky Way/Local Group/Virgo Supercluster
Code:
From Car as car inner join car.CarPart part where part='Door'

Please, don't forget to rate.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 21, 2006 3:38 am 
Newbie

Joined: Tue Mar 07, 2006 4:54 am
Posts: 6
accidentally clicked the no (instead of yes). can you post again and i will re-rate?

10x!


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 21, 2006 4:51 am 
Expert
Expert

Joined: Thu Sep 22, 2005 10:29 am
Posts: 285
Location: Almassera/Valencia/Spain/EU/Earth/Solar system/Milky Way/Local Group/Virgo Supercluster
Rate me ;-)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 21, 2006 4:53 am 
Newbie

Joined: Tue Mar 07, 2006 4:54 am
Posts: 6
zzyborg wrote:
hi assaf,
i wonder why u want to have a many to many relationship between a car and its parts . i would rather suggest a one-to-many relationship to car-parts .

then u can query like select p.car from parts p where p.partname='something'

correct me if im wrong


I might want to know which cars use a certain part (door)

Assaf


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