Win a copy of JDBC Workbook this week in the JDBC and Relational Databases forum
or A Day in Code in the A Day in Code forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • salvin francis
  • fred rosenberger

Spring Transaction-Programmatically

Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.

Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You said 2nd operation is failed but are you getting any exception ?
I guess everyone has an angle. Fine, what do you want? Just know that you cannot have this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
    Bookmark Topic Watch Topic
  • New Topic