java - Spring attach data to the current transaction -
is there way access current transaction in spring ? objective add information transaction when starts , use information in method calls within same transaction.
here solution ejb: how can attach data jta transaction? (or uniquely identify it) looking same spring.
you can attach data thread using threadlocal
, , use transactionsynchronizationmanager
clear threadlocal
, creating transaction scoped variable:
transactionsynchronizationmanager.registersynchronization( new transactionsynchronizationadapter() { @override public void aftercompletion() { ... clear threadlocal ... } } );
Comments
Post a Comment