-->
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: Cascade saves not saving map keys
PostPosted: Wed May 19, 2004 12:58 pm 
Newbie

Joined: Tue May 04, 2004 11:51 am
Posts: 8
Is there something special that needs to be done to get Hibernate to cascade the saving of key values when the map itself is saved? I'm getting the error message:

net.sf.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing

when I try to session.save(obj) where the object contains a map if I don't individually save the keys of the map (via session.save(key1), session.save(key2), etc.) first.

(Cascade saves of the map's *values* work fine.)

This is how my map container is defined:

Code:
   <class name="hibernate.HMap" table="HContainer">
      
      <id name="id" unsaved-value="0">
         <generator class="native"/>
      </id>
      
      <map name="map" table="HMap" cascade="all-delete-orphan">
         <key column="container_id"/>
         <index-many-to-many column="key_id"
            class="hibernate.HMapKey"/>
         <many-to-many column="value_id" class="hibernate.HMapValue"/>
      </map>
      
   </class>


The key:

Code:
   <class name="hibernate.HMapKey" table="HMap_key">
      <id name="id" unsaved-value="0">
         <generator class="native"/>
      </id>
      <property name="value"/>
   </class>


The value:

Code:
   <class name="hibernate.HMapValue" table="HMap_value">
      <id name="id" unsaved-value="0">
         <generator class="native"/>
      </id>
      <property name="value"/>
   </class>


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.