-->
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.  [ 4 posts ] 
Author Message
 Post subject: Many to Many query example
PostPosted: Tue Dec 07, 2004 8:48 pm 
Newbie

Joined: Tue Dec 07, 2004 8:15 pm
Posts: 10
Location: Adelaide Australia
Hibernate version:
2.1.3
Mapping documents:
N/A
Code between sessionFactory.openSession() and session.close():
N/A
Full stack trace of any exception that occurs:
N/A
Name and version of the database you are using:
HSQL
The generated SQL (show_sql=true):
N/A
Debug level Hibernate log excerpt:
N/A

Can anyone point me at a good example of a way to map a many to many as well as a query between 2 classes (say Foo and Bar) that encompasses the following features:

1. Foo and Bar both have single column ID's
2. There is an association table FooBar that has extra columns that need to be mapped
3. The association class FooBar is using a composite ID with a seperate key class
4. The query needs to find all Foo instances such that they contain a given Bar

I've tried so many different ways of doing this I've lost track. Surely there should be some example code somewhere that shows this?

_________________
Peter Kelley


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 07, 2004 8:55 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
This test case for Hibernate3 should help give you some idea:

http://cvs.sourceforge.net/viewcvs.py/h ... /test/cid/


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 07, 2004 8:56 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
(Note, however, that doing the same thing in HB2 is not quite identical.)


Top
 Profile  
 
 Post subject: Thanks
PostPosted: Wed Dec 08, 2004 12:27 am 
Newbie

Joined: Tue Dec 07, 2004 8:15 pm
Posts: 10
Location: Adelaide Australia
Thanks, those examples helped a lot.

I don't think I quite had the concept of mapping the columns as properties in the key versus mapping the entities in the many to many class. Once I had that figured out the query became much easier.

_________________
Peter Kelley


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