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.
|