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

Popular posts from this blog

hibernate - How to load global settings frequently used in application in Java -

python 3.x - Mapping specific letters onto a list of words -

objective c - Ownership modifiers with manual reference counting -