-->
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: how to define: Map<String, Set<Object>> in XML?
PostPosted: Tue Feb 13, 2007 2:59 am 
Regular
Regular

Joined: Thu May 26, 2005 12:20 am
Posts: 72
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

_________________
_________________
dan

If what I say is helpful, please rate the post as such by clicking 'Y'. I appreciate it.


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.