-->
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.  [ 9 posts ] 
Author Message
 Post subject: Custom Cascades?
PostPosted: Wed Dec 10, 2003 6:48 am 
Regular
Regular

Joined: Wed Aug 27, 2003 2:55 am
Posts: 90
Location: Sweden
Hi, is there any smart way to customize the cascades in Hibernate?

Consider the following object graph:

Code:
Table1 ---* Table2 *--- Table3
             |
             *
           Table4
             *
             |
           Table5


I'd like to have the following cascades:

Code:
* If a row in Table1 gets deleted, all related rows in Table2 should be
  deleted and the related rows in Table3 IF NOT those rows are related
  to other Table1 rows through Table2.

* If a row in Table3 gets deleted, all related rows in Table2 should be
  deleted and related rows in Table4. Related rows in Table5 should be
  deleted IF NOT the're related to some other Table3 row through Table4.


Could someone give me a hint?

Kind regards, Andreas


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 10, 2003 9:41 am 
Regular
Regular

Joined: Mon Sep 08, 2003 10:05 am
Posts: 50
Location: Dublin, Ireland
A database trigger would definitely allow u to code that.. assuming your DBMS supports triggers....


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 10, 2003 11:15 am 
Regular
Regular

Joined: Wed Aug 27, 2003 2:55 am
Posts: 90
Location: Sweden
Thanks for the respons!

Not "allowed" to use triggers or stored procedures.

Kind regards, Andreas


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 10, 2003 11:21 am 
Regular
Regular

Joined: Mon Sep 08, 2003 10:05 am
Posts: 50
Location: Dublin, Ireland
Ouch.. From what the manual says about cascades in Hibernate, I'd say you don't have a way to do this right now then..

Quote:
cascade="all|none|save-update|delete"


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 10, 2003 11:27 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Have a look at interceptor, might help.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 10, 2003 11:38 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Not Interceptor, but Lifecycle.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 10, 2003 11:48 am 
Regular
Regular

Joined: Wed Aug 27, 2003 2:55 am
Posts: 90
Location: Sweden
Lifecycle, ok thanks!

Kind regards, Andreas


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 10, 2003 2:16 pm 
Regular
Regular

Joined: Wed Aug 27, 2003 2:55 am
Posts: 90
Location: Sweden
Well, while I was searching this forum on 'Lifecycle' I found a post where Gavin said:

I don't use Lifecycle. I think it was a mistake. Its one of the very few things I just ripped unthinkingly from other ORM solutions back in the dim dark days.....

Is there another way of making the special cascades I'd like?

Seems like I bind my VO's to be only Hibernate VO's by implementing Lifecycle interface.

Another thing is; how can a Table3 VO tell that it's "parent" row in Table1, who's getting deleted, is the only one associated with the object?

Kind regards, Andreas


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 11, 2003 5:27 am 
Regular
Regular

Joined: Wed Aug 27, 2003 2:55 am
Posts: 90
Location: Sweden
Pushing it up....


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