Skip to content
Advertisement

Transaction marked as rollback only: How do I find the cause

I am having issues with committing a transaction within my @Transactional method:

JavaScript

When I call methodB() from methodA(), the method passes successfuly and I can see “OK” in my logs. But then I get

JavaScript
  1. The context of methodB is completely missing in the exception – which is okay I suppose?
  2. Something within the methodB() marked the transaction as rollback only? How can I find it out? Is there for instance a way to check something like getCurrentTransaction().isRollbackOnly()? – like this I could step through the method and find the cause.

Advertisement

Answer

I finally understood the problem:

JavaScript

What happens is that even though the methodB has the right annotation, the methodC does not. When the exception is thrown, the second @Transactional marks the first transaction as Rollback only anyway.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement