Hello I write tests for domain persistence layer implemented on Hibernate. I use JBoss microcontainer for the following purposes: 1. provide Datasources through JNDI 2. provide UserTransaction through JNDI
my tests fork fine. But I want to create database schema on every test run (I use HSQLDB in embedded mode). Schema update is unavailable, because I use LocalTxDataSources which use "test managed" UserTransaction. stack trace: SchemaUpdate - Running hbm2ddl schema update | SchemaUpdate - fetching database metadata | SchemaUpdate - could not get database metadata | java.sql.SQLException: You cannot set autocommit during a managed transaction! | at org.jboss.resource.adapter.jdbc.BaseWrapperManagedConnection.setJdbcAutoCommit(BaseWrapperManagedConnection.java:482) | at org.jboss.resource.adapter.jdbc.WrappedConnection.setAutoCommit(WrappedConnection.java:322) | at org.hibernate.tool.hbm2ddl.SuppliedConnectionProviderConnectionHelper.prepare(SuppliedConnectionProviderConnectionHelper.java:36) | at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:127) | at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:314) | at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1218) hibernate.cfg.xml | <property name="connection.datasource">java:comp/env/jdbc/XxxDataSource</property> | .... | <property name="hibernate.transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property> | <property name="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.WeblogicTransactionManagerLookup</property> | <property name="hibernate.transaction.flush_before_completion">true</property> | <property name="hibernate.transaction.auto_close_session">true</property> | ... | <property name="hibernate.hbm2ddl.auto">update</property> jboss-beans.xml with several datasources: | <bean name="MasterDSBootstrap" class="org.jboss.resource.adapter.jdbc.local.LocalTxDataSource"> | <property name="driverClass">org.hsqldb.jdbcDriver</property> | <property name="connectionURL">jdbc:hsqldb:file:test-output/master</property> | <property name="userName">sa</property> | <property name="jndiName">java:comp/env/jdbc/XxxDataSource</property> | | <bean name="SlaveDSBootstrap" class="org.jboss.resource.adapter.jdbc.local.LocalTxDataSource"> | <property name="driverClass">org.hsqldb.jdbcDriver</property> | <property name="connectionURL">jdbc:hsqldb:file:test-output/slave</property> | <property name="userName">sa</property> | <property name="jndiName">java:comp/env/jdbc/YyyDataSource</property> | "problem code" from SchemaUpdate.execute | log.info("fetching database metadata"); | connection = connectionProvider.getConnection(); | if ( !connection.getAutoCommit() ) { <<<---- i can return true there through extending datasource classes | connection.commit(); | connection.setAutoCommit(true); <<< --- exception throwing there | autoCommitWasEnabled = false; | } | this code from hibernate 3.0.5, the same (but with insignificant differences) in 3.2 What are you think about this? Which is the simplest way to solve this issue? Should I use nonTx Datasource's ? May be I have to extends LocalTxDataSource and WrappedConnection for return AutoCommit true always? thanks for your attention View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3988363#3988363 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3988363 _______________________________________________ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user