During programmatic schema export with CMT transactions following exception occurs.
This happend due to following code in SchemaExport.java (around 121 line)
Code:
if ( !connection.getAutoCommit() ) {
connection.commit();
connection.setAutoCommit(true);
}
Is there any way to avoid implicit connection.commit() (or disable connection's autocomit feature)?
Hibernate version: 2.1.7c
Full stack trace of any exception that occurs:java.sql.SQLException: You cannot commit during a managed transaction!
at org.jboss.resource.adapter.jdbc.BaseWrapperManagedConnection.jdbcCommit(BaseWrapperManagedConnection.java:525)
at org.jboss.resource.adapter.jdbc.WrappedConnection.commit(WrappedConnection.java:464)
at net.sf.hibernate.tool.hbm2ddl.SchemaExport.execute(SchemaExport.java:121)
at net.sf.hibernate.tool.hbm2ddl.SchemaExport.create(SchemaExport.java:84)
at install.InitializerHibernateImpl.createTables(InitializerHibernateImpl.java:70)
...
Name and version of the database you are using:MySQL 4.0.21, connection provided via JBoss datasource
JCA connector configuration:
Code:
<datasources>
<local-tx-datasource>
<jndi-name>mysql</jndi-name>
<connection-url>jdbc:mysql://localhost:3306/DB?useUnicode=true&characterEncoding=UTF-8</connection-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<user-name>scot</user-name>
<password>tiger</password>
</local-tx-datasource>
</datasources>
Hibernate configurationCode:
<hibernate-configuration>
<!-- a SessionFactory instance listed as /jndi/name -->
<session-factory>
<!-- properties -->
<property name="connection.datasource">java:/mysql</property>
<property name="dialect">net.sf.hibernate.dialect.MySQLDialect</property>
<property name="show_sql">true</property>
<property name="use_outer_join">false</property>
<property name="transaction.manager_lookup_class">net.sf.hibernate.transaction.JBossTransactionManagerLookup</property>
<property name="hibernate.transaction.factory_class">net.sf.hibernate.transaction.JTATransactionFactory</property>
<!-- mapping files -->
...
</session-factory>
</hibernate-configuration>