How can I determine whether I am in a transaction in Spring?
You can check if transaction is active using TransactionSynchronizationManager.isActualTransactionActive()
. But you should call it before a service method executing.
Also you can get status of current transaction using
TransactionStatus status = TransactionAspectSupport.currentTransactionStatus();
Besides, maybe a good point for you is to enable logging of transactions.
log4j.logger.org.hibernate.transaction=DEBUG
log4j.logger.org.springframework.transaction=DEBUG
You can use
org.springframework.transaction.support.TransactionSynchronizationManager#isActualTransactionActive