-->
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.  [ 2 posts ] 
Author Message
 Post subject: Conceptual collections and delete() question
PostPosted: Sun Jan 30, 2005 12:00 am 
Beginner
Beginner

Joined: Tue Nov 09, 2004 9:48 am
Posts: 23
Guys,

I'm a little confused about collections and deletions.

Say I have a class called Person, and that person has a list collection of Address objects.

If I manually delete an Address object from the database by calling session.delete(addressObj), is it then imperative that I get ahold of the containing Person object and do a person.getAddresses().remove(addressObj) as well, or can Hibernate do that for me?

I've searched the two books I have, the online manual, and the forum and haven't found an answer yet. I'm afraid the trees are impeding my view of the forest...


I appreciate any insight you can provide.

jbwiv


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 30, 2005 7:46 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Your example does result in the in-memory state not matching the databases current state (after a transaction commited). This is usually not a problem but it depends on the application context. The same thing happens with other collection operations. You can make the state match if you wish but the effort is not always required. Alternatively, you could delete the address from the collection and let the cascade settings trigger the delete operation. Hibernate is flexible.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.