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.  [ 1 post ] 
Author Message
 Post subject: Question for association among 3 tables
PostPosted: Thu Jan 04, 2007 1:15 pm 
Newbie

Joined: Thu Jan 04, 2007 1:02 pm
Posts: 3
I have the following situation :
A have many categories, each category have elements. For example the category "sex" has two elements: "male" and "female". I have objects, let say users which have elements for some of the category. If you have to implement this association with classes it will look something like this:

class User {
Map<Category, Elements> categoryElements;
}

class Category {
Set<Elements> elements;
}

class Elements {
String name;
}

To implements this in the db you will probably use table like: "user_and_category_to_element" which will have 3 columns : The userId, the categoryId and the elementId and unique constrain on the user and category ids pair. Something like many-to-may relation but among 3 tables.

My question is how to make mapping for this association with hibernate?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.