hi all!
I am using hibernate and spring and all my DAOs extend HibernateDAOSupport.
I have an entity 'Order' which contains an attribute 'Quote' and Quote contains collections of 'Buy' and 'Sell' values.
<class name="Order" table="ORDERS" lazy="false">
<id name="objectId" column="ORDER_UUID">
<generator class="uuid.hex"/>
</id>
<!-- for Quote -->
<many-to-one name="Quote" class="Quote"
column="quote_id"
cascade="all"
unique="true"/>
</class>
<class name="Quote" table="QUOTE">
<id name="id" column="QUOTE_ID">
<generator class="sequence">
<param name="sequence">quote_sequence</param>
</generator>
</id>
<map name="sell" table="sell" sort="natural">
<key column="quote_id"/>
<index column="price"/>
---------
</map>
<map name="buy" table="buy" sort="natural">
<key column="quote_id"/>
<index column="price"/>
---------
</map>
</class>
As you must have noticed, I am using lazy="false" and cascade="all" in Order mapping. So my Order object has all its collection initialized.
Now problem is when I stress test my code to store and update an order it throws the following error:
Illegal attempt to associate a collection with two open sessionsI Suppose reason is, the collections are not versioned like objects so when the same collection is opened with multiple sessions HB doesn't know who's going to win, as mentioned by Costin Leau in the following thread,
http://forum.springsource.org/showthread.php?t=26782Can any one please suggest me solution to it?
Any help is appreciated.
Thanks