-->
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: How to map many to many relationship with index on one side?
PostPosted: Sat Jan 06, 2007 6:07 am 
Newbie

Joined: Sat Jan 06, 2007 5:49 am
Posts: 3
We have 2 entities: Cat and Fish (species)
One cat eats many fishes, and one fish can be eaten by many cats.
They have a many to many relationship.

Interestingly, each cat have his/her own priority of favorite fishes, and index them by 1,2,...,n.

Now we want to operate on cats and fishes: create cat, set favorite fishes; create fish, set cats interest in him/her.

How can we model and mapping this? Especially the priority?


advTHANKSance


Top
 Profile  
 
 Post subject: meejoe
PostPosted: Sat Jan 06, 2007 9:37 am 
Beginner
Beginner

Joined: Sat Dec 16, 2006 9:53 pm
Posts: 31
Location: Brisbane, Australia
Does a cat to favour types of fish, or individual fishes? ie: Does Jerry like clown fish, or does he just have a particular hardon for Nemo?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 08, 2007 7:35 pm 
Newbie

Joined: Sat Jan 06, 2007 5:49 am
Posts: 3
Cats and fishes are all species here, not individual ones.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 10, 2007 12:37 am 
Newbie

Joined: Tue Nov 21, 2006 2:14 am
Posts: 7
Location: Chennai, India
i believe this is more of an issue with the design of the table than with hibernate.

you can try using the many-to-many relationship with an intermediate table. refer to the hibernate docs for example.

hope this solves your problem.

rate if it does


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 10, 2007 7:28 pm 
Newbie

Joined: Sat Jan 06, 2007 5:49 am
Posts: 3
thanks cobra82.

For many to many relationship, it requires an intermediate table, the question now is whether I need a intermediate class as well, which has the index as its property? If not, how can I map the Cat and Fish classes.

any response is welcome


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 11, 2007 7:33 am 
Beginner
Beginner

Joined: Sat Dec 16, 2006 9:53 pm
Posts: 31
Location: Brisbane, Australia
mejooe, add this one to your favourites http://www.hibernate.org/hib_docs/v3/re ... orial.html

... down the bottom (1.3.5. Bi-directional associations) it explains how to map many-to-many's

Keith.


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.