• 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

Spring Transaction-Programmatically

 
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am trying to do an example of Spring transaction (Programmatically) .

I have 2 db operation.

1st operation: I am going to purchase a product which needs to be updated in PurchaseProduct table as well as updated(2nd operation) in the product table.

I have following code



I would like to test the transaction to be failed. So I did the code accordingly where the 1st operation pass but the 2nd operation should fail so that the whole transaction should be roll back.
But when I run the code, the table PurchaseOrder1 is updated i.e 1st operation pass and Product1  is not updated i.e 2nd operation fail. But the whole transaction is not rolled back.

I expect that PurchaseOrder1  table should not be updated as Product1  is not updated.

I am not able to figure out for the solution.

Please help.

Thanks,
Siddharth
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You said 2nd operation is failed but are you getting any exception ?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic