• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
sam White
Ranch Hand
Posts: 229
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
reply
    Bookmark Topic Watch Topic
  • New Topic