简体   繁体   中英

How to run update/remove operations without transaction in spring jpa

I have a non-web application that will run in background, during its run period I don't need any transactions. I must ensure that every jdbc operation should be automatically committed immediately, but spring jpa doesn't allow that happened.

How could I avoid TransactionRequiredException without transaction opened ??

Open a transaction. If you don't need an extended transaction and just want to do a quick update and commit it, you still need a transaction; just put @Transactional on the one method (or grab an EntityManager ) and finish everything right there.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM