Java JPA + 休眠 + 自动提交

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1228086/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-12 01:09:00  来源:igfitidea点击:

JPA + Hibernate + autocommit

javahibernatejpa

提问by adrian.tarau

Does anybody know why I get this warning when I turn off the auto-commit in JPA configuration file?

有人知道为什么在关闭 JPA 配置文件中的自动提交时会收到此警告吗?

Using this setting :

使用此设置:

<property name="hibernate.connection.autocommit" value="false"/>

generates this warning :

生成此警告:

2009-08-04 09:54:10,621 [main] WARN org.hibernate.ejb.Ejb3Configuration - hibernate.connection.autocommit = false break the EJB3 specification

How would this break EJB3 specification?

这将如何破坏 EJB3 规范?

采纳答案by Chris Gummer

From section 13.3.4 of the EJB 3.0 specification:

来自 EJB 3.0 规范的第 13.3.4 节:

The enterprise bean's business methods, message listener methods, business method interceptor methods,life cycle call back interceptor methods, or timeout callback method must not use any resource-manager speci?c transaction management methods that would interfere with the container's demarcation of transaction boundaries. For example, the enterprise bean methods must not use the following methodsof the java.sql.Connection interface:commit, setAutoCommit, and rollback; or the following methods of the javax.jms.Session interface:commit and rollback.

企业 bean 的业务方法、消息侦听器方法、业务方法拦截器方法、生命周期回调拦截器方法或超时回调方法不得使用任何会干扰容器划分事务边界的资源管理器特定事务管理方法。例如, 企业 bean 方法不得使用java.sql.Connection 接口的以下方法:commit、 setAutoCommit和 rollback;或者javax.jms.Session接口的以下方法:commit和rollback。