- 在從 5.1 升到 5.2及以上 時遇到這個問題了
- 像是嵌套事務問題
Caused by: javax.persistence.TransactionRequiredException: no transaction is in progress
at org.hibernate.internal.SessionImpl.checkTransactionNeeded(SessionImpl.java:3552)
at org.hibernate.internal.SessionImpl.doFlush(SessionImpl.java:1444)
at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1440)
解決方案如下:
Hibernate now conforms with the JPA specification to
not allow flushing updates outside of a transaction boundary.
To restore 5.1 behavior, allowing flush operations outside of a transaction boundary,
set hibernate.allow_update_outside_transaction=true.
Hibernate現在符合JPA規范,不允許刷新事務邊界之外的更新。要恢復5.1行為,
允許事務邊界之外的刷新操作,請設置hibernate.allow_update_outside_transaction=true。
from Hibernate ORM 5.2
在hibernate配置文件增加如下語句:
<prop key="hibernate.allow_update_outside_transaction">true</prop>
