It's not a secret anymore!*
The moose likes Object Relational Mapping and the fly likes How to create atomic Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "How to create atomic "save all or none" for "save" operation accrosing multiple tables." Watch "How to create atomic "save all or none" for "save" operation accrosing multiple tables." New topic
Author

How to create atomic "save all or none" for "save" operation accrosing multiple tables.

sam White
Ranch Hand

Joined: Feb 18, 2011
Posts: 208
Hi, With spring 3.0.7 and hibernate 4, I created two EAR projects - fontend and backend.
In the font-end ear project, I implemented a cascadeAddProductAndImage function with the following implementation:



where the above three "create()" calls will save a newly created product info into 3 separate database tables.
The issue is if the last one eg. productArgicleService.create(articleList) failed, the productService.create(c) and productCategoryAssociateSerivce.create(..) still executed succesfully. This might not be a big issue as they don't violate database relational integrity. But is there any way I can use to roll back the operations if one of the create() failed?

Any suggestion is very will appreciated.
Sam
 
Consider Paul's rocket mass heater.
 
subject: How to create atomic "save all or none" for "save" operation accrosing multiple tables.