-->
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: Transactoin behavior for cascade
PostPosted: Wed Apr 28, 2010 7:12 pm 
Newbie

Joined: Mon Jun 05, 2006 11:44 am
Posts: 11
Quick question (couldn't find answer on first scan through documentation):

If Hibernate mappings define cascade behavior, does Hibernate automatically wrap deletes/updates/saves within a transaction?

For example, if I had a Person object that had Set<Children> and cascade was configured to cascade on delete/save/update for that set, would I get (using pseudo SQL)?

Java:
Code:
Session = someMethodToGetHibernateSession();
Person p = myloadPersonAndChildrenMethod();
session.delete(p);


Some Generated SQL:
Code:
TRANSACTION BEGIN;
DELETE FROM person WHERE parent_id = 1; -- deletes children
DELETE FROM person WHERE id = 1; -- deletes person (parent)
TRANSACTION COMMIT;


Or do I have to handle transactions myself?


Top
 Profile  
 
 Post subject: Re: Transactoin behavior for cascade
PostPosted: Thu Apr 29, 2010 9:36 am 
Newbie

Joined: Wed Mar 03, 2010 3:36 am
Posts: 5
It is always better to use Transaction your self.Because if you doing multiple operation
e.g. delete or updation and one of the operation will fail to execute then in that case
all the operation will rollback.


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.