-->
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.  [ 1 post ] 
Author Message
 Post subject: HashMap persistence
PostPosted: Fri Sep 23, 2011 11:06 am 
Newbie

Joined: Fri Sep 23, 2011 10:52 am
Posts: 4
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.