Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: 3.1.3
Here's an example of the type of map I want to create:
TABLE User { user_id, name }
TABLE User_Relative_Relation { user_id, relative_id, relation_type }
where User_Relative_Relation columns user_Id and relative_id are both Foreign keys back to User.user_id, and relation_type is a String such as 'brother' or 'nephew'.
I would like to be able to reference through Java:
Set<User> brothers = myUser.relatives['brother'];
and get back a Set of all User objects mapped in the relation table to the myUser user as type 'brother'.
The mapping:
Code:
<map name="relatives" cascade="save-update" table="USER_RELATIVE_RELATION">
<key column="user_id"/>
<map-key type="string" column="relation_type" />
<many-to-many class="User" column="relative_id"/>
</map>
seems intuitive to me since I am adding a many-to-many to how i would map it as a one to many with a table, but that is not correct.
Any suggestions or starter tips would be most appreciated!
Thanks.
Dan