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.