9

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

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?

adrian.tarau
  • 3,124
  • 2
  • 26
  • 29

1 Answers1

5

From section 13.3.4 of the EJB 3.0 specification:

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 specific 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 methods of the java.sql.Connection interface:commit, setAutoCommit, and rollback; or the following methods of the javax.jms.Session interface:commit and rollback.

Chris Gummer
  • 4,772
  • 1
  • 24
  • 17
  • 1
    I don't have any methods like that, the message occurs only if I set hibernate.connection.autocommit=true in JPA configuration. – adrian.tarau Nov 04 '09 at 12:16
  • Hibernate probably calls that method itself. I'm guessing you don't need to specifiy autocommit=false – Miguel Ping Nov 13 '09 at 14:35
  • 1
    Not sure about that. Here is what the code looks like: //some spec compliance checking 857 //TODO centralize that? 858 if ( ! "true".equalsIgnoreCase( cfg.getProperty( Environment.AUTOCOMMIT ) ) ) { 859 log.warn( Environment.AUTOCOMMIT + " = false break the EJB3 specification" ); 860 } Also something from docs: hibernate.connection.autocommit : Enables autocommit for JDBC pooled connections (it is not recommended).e.g. true | false I presume it's just a warning as Miguel noted(not sure if it is still used) and since you must start a transaction anyway, this doesn't makes sense now. – adrian.tarau Dec 27 '09 at 05:52
  • Ok, didn't come out well, code in comments doesn't work. Conclusion : not need it, you will have to start a transaction even for inserting a single record(you get an exception if you don't). Still I cannot find a document saying that this is obsolete(or some better explanation). – adrian.tarau Dec 27 '09 at 05:54