-->
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: How to remove whole object graph using DML-Style removal?
PostPosted: Wed Feb 15, 2006 6:48 pm 
Beginner
Beginner

Joined: Mon Sep 22, 2003 5:18 am
Posts: 28
Hi,
In Hibernate3.1x it is possible to use DML-style for update/insert/delete operations on Hibernate entities. Suppose I have an object graph that I need to remove by deleting parent object.
In non-DML style it would look like:
Code:
session.delete(objectInstance)

which would cause cascade deletion for all child objects with cascade="all" in mapping file.

Correspondent DML-style will be similar to this:
Code:
String hqlUpdate = "delete SomeObject someObject where someObject.id = :id";
session.createQuery(hqlUpdate).setLong("id", realId).executeUpdate();

This would produce SQL, similar to the following:
Code:
DELETE FROM SOME_OBJECT WHERE SOME_OBJECT_ID=?


This would cause runtime error due to possible database data integrity constraint (assume no cascade propagation constrains on database level).

The question is - how to tell Hiberante to traverse whole object graph for cascade update/delete in DML-style update/delete impl. ?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 15, 2006 11:01 pm 
Beginner
Beginner

Joined: Mon Sep 22, 2003 5:18 am
Posts: 28
does anyone use DML-style update feature?


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.