[英]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. 我有一个非Web应用程序,它将在后台运行,在运行期间,我不需要任何交易。 I must ensure that every jdbc operation should be automatically committed immediately, but spring jpa doesn't allow that happened.
我必须确保每个jdbc操作都应立即自动提交,但是spring jpa不允许这种情况发生。
How could I avoid TransactionRequiredException without transaction opened ?? 如果未打开事务,如何避免TransactionRequiredException?
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. 只需将
@Transactional
放在一个方法上(或获取EntityManager
),然后就可以完成所有操作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.