-->
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.  [ 4 posts ] 
Author Message
 Post subject: Can I switch between cascade all and all-delete-orphon?
PostPosted: Fri Jan 21, 2005 11:13 pm 
Senior
Senior

Joined: Sun Oct 26, 2003 5:05 am
Posts: 139
Can I switch between cascade all and all-delete-orphon at runtime? If so, how? If not, what is the workaround?

The problem is that I have a many-to-one relationship (object A contains many B's) where I simply want to dissociate B from A (by setting the reference to null) while deleting B in other cases.

In the cases where I say cascade="all", saveOrUpdate() will actually disassociate B from A in the database properly if I go B.setA( null ). If I do A.getBs().remove( b ), Hibernate will delete b. This is working fine.

However, if I delete() object A, it won't delete any of the B's unless I use cascade="all-delete-orphan".

Now, I know I can delete the B's seperately. However, this causes a problem since the decision to delete B happens deep in the domain logic. If I want to continue using cascade="all", I will have to pull this logic out of the domain layer and move it up into the server layer where I can access Hibernate DAO objects.

Can anyone help me out? If you don't understand what I'm talking about, I'll try to clarify.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 22, 2005 4:56 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
No


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 22, 2005 10:06 am 
Senior
Senior

Joined: Sun Oct 26, 2003 5:05 am
Posts: 139
Okay. I'll just try and do a compare between the original list and the new one and delete them in the service layer then. Thanks Christian.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 22, 2005 10:09 am 
Senior
Senior

Joined: Sun Oct 26, 2003 5:05 am
Posts: 139
Actually, would it be a major design change to pass a cascading strategy to save/saveOrUpdate/etc? Or is it a bigger problem than that? Just curious.


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