-->
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.  [ 3 posts ] 
Author Message
 Post subject: newbie: saveOrUpdate does not update Collection
PostPosted: Thu Dec 15, 2005 9:28 am 
Newbie

Joined: Tue Dec 13, 2005 5:43 pm
Posts: 5
hello,
I have a POJO which contains a Set:

Code:
public class GeOutage  implements java.io.Serializable {
     private Set geOutageComponents;
}


When I am trying to remove an item from the POJO's set and store it to the database again, the changes are not updated. My outage-POJO is clearly updated, though...

Code:
GeOutage outage = (GeOutage)session.load(GeOutage.class, id);
Set outageComponents = outage.getGeOutageComponents();
outageComponents.remove(outageComponentToRemove);
Transaction transaction = session.beginTransaction();
session.saveOrUpdate(outage);
transaction.commit();


I guess this is basic Hibernate knowledge, but I just don't seem to get it... Why is my POJO updated, but the database not? My GeOutage.hbm.xml has the following setting:

Code:
   
<set name="geOutageComponents" lazy="true" inverse="true" cascade="all">
     <key>
         <column name="GEO_ID" />
     </key>
     <one-to-many class="GeOutageComponent"/>
</set>



Any help would be highly appreciated.

cheers,
Kenny


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 15, 2005 10:39 am 
Have you tried this with lazy="false"? I am new also, but it would be something I would try.


Top
  
 
 Post subject:
PostPosted: Thu Dec 15, 2005 10:55 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
<set name="geOutageComponents" lazy="true" inverse="true" cascade="all">

you seem to have a bidirectionnal association (inverse=true) so
Set outageComponents = outage.getGeOutageComponents();
outageComponents.remove(outageComponentToRemove);

isn't enough, you must manage the other association end as explained in most of the docs, wiki, books, tuto, articles,.....

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


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

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.