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.
|
|