javax.persistence.TransactionRequiredException: no transaction is in progress

(暂)通常是因为不适当的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即可。

你可能感兴趣的:(@Transactional,JPA,Spring)