|
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?
|