-->
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: update is not deleting objects from collection in db
PostPosted: Mon Jul 28, 2008 10:16 pm 
Beginner
Beginner

Joined: Thu Apr 15, 2004 2:01 pm
Posts: 25
I have obj which has set in it.
Code is updating set with addition and removal of objects. Adding works fine with database but remove element from collection and calling save is not deleting element from db. I am not getting any exception too.

Code is as follows:

Set<Organization> currentOrgs = center.getOrgs();
Organization org = orgDAO.getOrg(10); //this org exists in currentOrgs.
currentOrgs.remove(org);
centerDAO.update(currentOrgs);

hbm mapping contains many to many relation

<set name="orgs" inverse="true" table="dbo.ORG">
<key>
<column name="CENTER_ID" not-null="true"/>
</key>

<many-to-many entity-name="com.planner.db.Organization">
<column name="ORG_ID" not-null="true"/>
</many-to-many>
</set>

Thanks in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 29, 2008 7:33 am 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
What about setting up a CascadeType of ALL with DELETE ORPHAN?

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


Top
 Profile  
 
 Post subject: Problem solved
PostPosted: Tue Jul 29, 2008 9:12 am 
Beginner
Beginner

Joined: Thu Apr 15, 2004 2:01 pm
Posts: 25
It worked setting inverse = false

Thank you for your help.


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.