-->
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: Deleting and Process-Level Cache : Best Practices?
PostPosted: Mon Mar 22, 2004 6:51 pm 
Regular
Regular

Joined: Tue Sep 16, 2003 11:35 am
Posts: 93
Location: San Francisco, CA
I have a parent child relationship:

Parent --* Child

* Parent cascades all to Child
* class Parent and collection Parent.children are in a process level cache

I want to be able to delete either a Parent -- with cascades to all it's children -- or a Child by itself.

Deleting the Parent is easy:
Code:
session.delete(parent);


This is how I was trying to delete the child:
Code:
session.delete(child);

// in class Child:
public boolean onDelete( Session session ) {
   parent.getChildren().remove(this);
}


This code works for deleting all traces of the child ... but breaks the first code example of deleting the parent. This is because modifying the children Collection throws a ConcurrentModificationException since Hibernate is also iterating over the children, processing the cascades.

Is there any way to handle this elegantly? I know that I can create an onDelete() method in Parent that clears the parent of each child but this is ugly since the whole point of cascades is that they are declarative.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 20, 2004 6:08 am 
Regular
Regular

Joined: Thu Feb 05, 2004 6:51 am
Posts: 50
Did you find a way around this issue, I do have the same configuration and the same exception also ?

Vlad


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 20, 2004 6:14 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Whats wrong about all-delete-orphan cascades? Just break up the relationship in your java code and Hibernate will handle the cascades.


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.