ARTICLE AD BOX
You can use TransactionSynchronizationManager to check this at runtime:
public class MyService {
@Transactional
public void doSomething() {
boolean isActive = TransactionSynchronizationManager.isActualTransactionActive();
System.out.println("Transaction active: " + isActive); // true
}
}
If @Transactional is working correctly, isActualTransactionActive() returns true.
Note: make sure you're calling this method through a Spring proxy (i.e. from another bean),
not from within the same class — otherwise @Transactional won't work at all./
New contributor
projectsrv007 is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
Explore related questions
See similar questions with these tags.
