How to ensure MySQL connection of Spring @Transactional annotation use is the same with the one in method?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



How to ensure MySQL connection of Spring @Transactional annotation use is the same with the one in method?



If use @Transactional to annotate a method, the method will be transactional. If use DataSourceTransactionManager as transactionManager, JDBC connections will be managed.


DataSourceTransactionManager



Example:


@Transactional
public void insertOrder()
//insert log info
//insertOrder
//updateAccount



It seems that @Transactional help a DB connection start a transaction, insertOrder and updateAccount will use the same connection to modify data.


@Transactional


insertOrder


updateAccount



How does it do this?









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

Creating a leaderboard in HTML/JS