-->
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: what is wrong with this mapping?
PostPosted: Mon Apr 18, 2005 2:30 am 
Regular
Regular

Joined: Tue Oct 12, 2004 9:02 am
Posts: 66
Location: Italy
I have an User who has 2 set of Area associated.
I used the follow mapping, but when I save the user hibernate say "found shared references to a collection":

-User.hbm.xml:

<hibernate-mapping default-cascade="save-update">
<class name="model.User" table="USERS" lazy="true">
........
<set name="areas" lazy="true" inverse="true" >
<key>
<column name="USER_FK"/>
</key>
<one-to-many class="model.UserArea"/>
</set>

<set name="newsAreas" lazy="true" inverse="true" >
<key>
<column name="USER_FK"/>
</key>
<one-to-many class="model.NewsUserArea"/>
</set>
....


-UserArea.hbm.xml:

<hibernate-mapping default-cascade="save-update">
<class name="model.UserArea" table="USER_AREA" lazy="true">

.....
<many-to-one name="area" class="model.Area">
<column name="AREA_FK" />
</many-to-one>

<many-to-one name="user" class="model.User">
<column name="USER_FK" />
</many-to-one>

</class>
</hibernate-mapping>



-NewsUserArea.hbm.xml:

<hibernate-mapping default-cascade="save-update">
<class name="model.NewsUserArea" table="NEWS_USER_AREA" lazy="true">

.....
<many-to-one name="area" class="model.Area">
<column name="AREA_FK" />
</many-to-one>

<many-to-one name="user" class="model.User">
<column name="USER_FK" />
</many-to-one>

</class>
</hibernate-mapping>


-Area.hbm.xml

<hibernate-mapping default-cascade="save-update">
<class name="model.Area" table="AREAS" lazy="true">
....

<property name="name" type="string">
<column name="NAME" not-null="false" unique="false"/>
</property>

....


(in Area.hbm.xml I didn't use any one-to-many mapping beucase I don't need a reference from Area to the 2 sets).


What is wrong with this mapping? And what does it means "found shared referecens to a collection" ?

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 18, 2005 2:57 am 
Regular
Regular

Joined: Tue Oct 12, 2004 9:02 am
Posts: 66
Location: Italy
sorry.....it was a really stupid problem (the gets method of aras and newsAreas returned both the areas set! instead of the 2 sets).


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.