javax.persistence.TransactionRequiredException: no transaction is in progress

来源:互联网 发布:php array shift函数 编辑:程序博客网 时间:2024/05/01 21:10

(暂)通常是因为不适当的flush() 引起异常的 。。。

When persisting a transient entity during manual flush, an exception "javax.persistence.TransactionRequiredException: no transaction is in progress" is thrown, unless getEntityManager().joinTransaction() is executed prior to flush() - despite declaring the POJO as @Transactional and using Seam-managed transactions and persistence contexts.

When persisting a managed entity, however, no exceptions are thrown and update completes normally.


解决方案:

在Dao类上添加注解@Transactional即可。

原创粉丝点击