views:

1507

answers:

2

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?

A: 

Without knowing the context it could be a few things, but try this

puug
I don't think there is any special context, it just gives me the warning if I set hibernate.connection.autocommit=true
adrian.tarau
+1  A: 

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
I don't have any methods like that, the message occurs only if I set hibernate.connection.autocommit=true in JPA configuration.
adrian.tarau
Hibernate probably calls that method itself. I'm guessing you don't need to specifiy autocommit=false
Miguel Ping
Not sure about that. Here is what the code looks like://some spec compliance checking857 //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
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