Win a copy of Cloud Native PatternsE this week in the Cloud forum
or Natural Language Processing in the AI/ML 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 ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Spring Transaction-Programmatically

 
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
You said 2nd operation is failed but are you getting any exception ?
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!