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

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -

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