-->
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.  [ 1 post ] 
Author Message
 Post subject: Help creating single transaction from a series of db actions
PostPosted: Wed Jun 09, 2010 7:21 pm 
Newbie

Joined: Wed Jun 09, 2010 3:36 pm
Posts: 1
I had a hard time searching for a similar topic so I'm posting a new one.

My application uses hbm.xml files for hibernate objects and hibernate 3. There is a large form the user fills out and after it validates, the series of database procedures begins.

A service method processes the form model object and :

1. a parent object is created and saved using getHibernateTemplate
2. a series of child objects are created and saved using getHibernateTemplate
3. a second series of other child objects are created and saved using getHibernateTemplate that reference the parent object ID and each one of the other child object IDs
4. a third series of child objects is created that each reference one of the second child objects

So, currently, if one of these database actions fails, I'm left with a parent object in the database and some of the child objects up until the point of failure.
I'm guessing there's a way to set it up as a Hibernate single transaction that either all succeeds or all fails. I just don't know where to find how to do this. Everytime I need to save an object I save it, and return the saved object, get the ID and add that to the next object in the method that needs that ID value.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.