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.  [ 6 posts ] 
Author Message
 Post subject: cascade delete
PostPosted: Thu Jan 08, 2004 7:46 am 
Newbie

Joined: Thu Oct 23, 2003 6:12 am
Posts: 18
Can anybody tell me if there is a way to know in advance which objects will be deleted (or nullified or else) when deleting a certain object. (offcourse taking into account any cascade definitions)

thanks,

Bas


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 08, 2004 8:56 am 
Expert
Expert

Joined: Fri Nov 07, 2003 4:24 am
Posts: 315
Location: Cape Town, South Africa
If you delete an object that has a 1-* relationship that is marked to cascade deletes, then all the child objects should be deleted.
I'm not sure if I understand exactly what you want - are you wanting some sort of pre-delete callback/notification on an individual object basis (for auditing purposed say)?

J


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 08, 2004 10:02 am 
Newbie

Joined: Thu Oct 23, 2003 6:12 am
Posts: 18
I just want to warn/inform my user what he is about to delete/do, when an object is deleted a lot happens (foreign keys are nullified, in the case of all-delete-orphan some objects will be cascade deleted) I just want some insight on what hibernate is about to do.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 08, 2004 10:07 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Well, Hibernate does what it has been told by you, in the mapping metadata. So it would be easy to add warning messages to your application after you specified the cascading deletes.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 08, 2004 10:41 am 
Newbie

Joined: Thu Oct 23, 2003 6:12 am
Posts: 18
>So it would be easy to add warning messages to your application after you specified the cascading deletes

I don't think it will be easy to inform my user what objects are deleted and rows nullified since I have to mimic Hibernate's cascade behaviour (I think I can get the cascade metadata via the meta api) "by hand". I have to walk though the complete object-graph using the cascade meta data, it would be a lot easier if Hibernate is able to dry-run and generate the SQL/info and not execute it but return it (in an structured way)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 08, 2004 10:46 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
But you have to specify the cascading yourself in the first place when you write the mappings? And this information has to exist outside of Hibernate, too?

I'd say that your domain model is the right place to decide what gets deleted when (cascading entity associations or "composition"). The mapping declaration for Hibernate is just an implementation of that model, as is the user interface/interaction in your application.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


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