I have a many-to-many associations using an association table
<class name="Deal" table="DEAL">
<id name="dealId" column="DEAL_ID" type="java.lang.Long">
<generator class="sequence">
<param name="sequence">DEAL_ID_SEQUENCE</param>
</generator>
</id>
<idbag name="partyDealAssocList" lazy="false" cascade="save-update" table="PARTY_DEAL_ASSOC" order-by="party_profile_id">
<collection-id type="long" column="PARTY_DEAL_ASSOC_ID">
<generator class="sequence">
<param name="sequence">PARTY_DEAL_ASSOC_SEQ</param>
</generator>
</collection-id>
<key column="DEAL_ID"/>
<many-to-many class="PartyProfile" column="party_profile_id"/>
</idbag>
...
</class>
My Association Table has
DEAL_ID
PARTY_PROFILE_ID
Lets say
Deal1 -> PartyProfile1
Then I create a copy of Deal1, but Deal2 still needs to point to B1 so
Deal2 -> PartyProfile1
This one saves properly. But on the next httprequest I opened both Deal1 and Deal2 in the same session.
Deal1 opens a PartyProfile with similar PartyProfileID as Deal2, but they do not reference the same object
When I commit the transaction I'm getting the exception:
net.sf.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session
Can I load both Deal1 and Deal2 in a single session and they point to a single reference of PartyProfile?
|