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

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -