-->
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: Many to Many through two link tables
PostPosted: Wed Jan 28, 2004 5:44 pm 
Newbie

Joined: Wed Jan 28, 2004 5:04 pm
Posts: 4
I have the following Tables in my database:
    Person
    Category
    Person_Category
    Category_Content
    Content

A Person has a many to many relationship to Categories.

A Category has a many to many relationship to Content.

Therefore a Person has a many to many relationship to Content.

I would like to design my objects w/o creating a Category Object. I would like a collection of available Content in Person. So I want to create a mapping from Person to Content. The mapping would have to link across Person_Category and Category_Content.


Code:
person    --- person_category --- category_content --- content
---------     ---------------     ----------------     ----------
person_id     person_id           category_id          content_id
              category_id         content_id


It's not obvious to me how to map Person to Content through the two link tables

What would be the hibernate mapping syntax to do this? Thanks in advance for any examples[list=][/list]


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 29, 2004 12:17 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
So have you considered how, when adding a Content to a Person, hibernate is supposed to know which category to add it to? Even if it were possible to map such a thing, there would be no way for Hibernate to know the answer to that question.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 30, 2004 2:34 pm 
Newbie

Joined: Wed Jan 28, 2004 5:04 pm
Posts: 4
Good point, I created a named Query instead.

Thanks


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.