-->
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: Mapping an "Association class" or "role"
PostPosted: Thu Jan 08, 2009 10:01 am 
Newbie

Joined: Thu Dec 18, 2008 8:14 am
Posts: 2
Hi,

I want to model an "association-class" or to be more precise the "role" of an object in an association :

I've got a "group" class and a "person" class already.

A group has a direct reference to the 'supervisor' person but i want to model the fact that a group has a set of persons, said 'vips' linked via a role (some are 'Main staff', others 'special guest'... etc)

Code:
GROUP<----role---->PERSON


in summary, i would have a join table like this :

GROUP_ID(int), ROLE(String), PERSON_ID(int)

I tried :

Code:
(in group.hbm...)

<set name="vips" table="XREF_VIPS_OF_GROUP" lazy="true">
         <key column="GROUP_ID" />
         <composite-element
            class="com.VipRepresentation">
            <property name="role" column="ROLE" />
            <many-to-one column="PERSON_ID" name="person"
               class="com.Personne" />
         </composite-element>
      </set>


1) It seems to work but i got some delete + insert when i simply load groups ???

2) Given a person, can i retreive groups it is linked on ? (can this association be bi-directionnal?)

Thanks for your feedback.


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.