Hi
The class StoreAuto contains an HashMap that contains an Object in the Key and value
Code:
Class CarShoop{
HashMap<Car,Wheel> carShoop = new HashMap<Car,Wheel>();
...
}
The mapping used is
<map name="mapCarShoop" cascade="all">
<key column="id"/>
<index-many-to-many column="carkey_id" class="com.nsn.Car"/>
<many-to-many column="wheelVal_id" class="com.nsn.Wheel"/>
</map>
The problem is. When I want to save my model I do
Code:
session.save(storeAuto);
,
but this shows the following exception
Code:
org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing:
I discover that I can solve the problem if I save first the key and only later the storeAuto object
Code:
session.save(car1);
session.save(storeAuto);
,
So in resume, why it's necessary in a HashMap to store first the keys (used in the hashMap) and only later the object that contains the HashMap?
Thanks in Advance