-->
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.  [ 2 posts ] 
Author Message
 Post subject: mapping two entities as a set
PostPosted: Thu Mar 30, 2006 5:53 pm 
Newbie

Joined: Tue Oct 19, 2004 4:05 am
Posts: 14
Location: ireland
I've three tables AppUser, AppRole and AppUserRole. The first two are entities but since all roles are being assigned to AppUser entity I want to avoid creating an entity for the third table. The AppUserRole table has the following structure
id->int
AppUser_id->FK_To_AppUser
App_Role_id->FK_To_AppRole

Is it possible to have some kind of set in AppUser entity? I tried to map my AppUser entity as follow

<class name="AppUser" table="AppUser" >
<id name="id" type="integer">
<column name="id" />
<generator class="native" />
</id>
<property name="login" type="string">
<column name="Login" length="10" not-null="true" />
</property>
<property name="firstName" type="string">
<column name="FirstName" length="20" />
</property>
<property name="lastName" type="string">
<column name="LastName" length="20" />
</property>

<set name="rolesSet" lazy="false" table="AppUserRole">
<key column="AppUser_id"/>
<one-to-many class="AppRole"/>
</set>

</class>

Unfortunatelly without success :(


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 30, 2006 6:16 pm 
Expert
Expert

Joined: Mon Jan 09, 2006 5:01 pm
Posts: 311
Location: Sacramento, CA
change your one-to-many to
many-to-many and do the same with the other AppRole if you want bi-directional association.

_________________
-JT

If you find my replies helpful, please rate by clicking 'Y' on them. 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.  [ 2 posts ] 

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.