I'm facing a mystifying problem that I assume is my fault and simple to solve, I just can't seem to find it.
For various reasons we're switching from the Hibernate mbean (com.code42.hibernate.jmx.HibernateService) to a configuration based upon hibernate.cfg.xml that uses c3p0. All of the configuration parameters have been moved over to the new file, the mbean config has been removed, c3p0 is starting properly, and everything looks just great EXCEPT committing (or rolling back) transactions. When our code calls commit JTATransaction apparently receives the command but the database shows no sign of it in the log.
Instead of a 'commit' which mysteriously doesn't appear, the connection is closed, checked back into c3p0, and the pool does its rollback when it gets the connection back (default behavior).
I've debugged the code both in the new environment and old and verified that JTATransaction.commit() is called normally and the line 'ut.commit();' IS executed. However, stepping over the line shows no entry in the debug log in my new environment. This issue has also been replicated with the latest c3p0 (.9+) and postgresql.
Any ideas would be appreciated, thank you!
Hibernate version: 3.0.3
c3p0 version: 0.8.5.2
jboss version: 3.2.5
Code between sessionFactory.openSession() and session.close():
Name and version of the database you are using: MySQL 4.1
Debug level Hibernate log excerpt: This is what JTATransaction sees when commit is called:
DEBUG [org.hibernate.jdbc.AbstractBatcher] closing statement
DEBUG [org.hibernate.event.def.AbstractFlushingEventListener] post flush
DEBUG [org.hibernate.transaction.JTATransaction] commit
DEBUG [org.hibernate.transaction.CacheSynchronization] transaction before completion callback
DEBUG [org.hibernate.jdbc.JDBCContext] before transaction completion
DEBUG [org.hibernate.impl.SessionImpl] before transaction completion
DEBUG [org.hibernate.transaction.CacheSynchronization] transaction after completion callback, status: 3
DEBUG [org.hibernate.jdbc.JDBCContext] after transaction completion
DEBUG [org.hibernate.impl.SessionImpl] after transaction completion
DEBUG [org.hibernate.transaction.JTATransaction] Committed JTA UserTransaction
MySQL log excerpt: This is what the database log shows. The 'rollback' comes from c3p0 reclaiming the connection. There is no commit command?
060720 14:25:24 308 Execute [29] [my last sql command in the tx]
060720 14:25:41 308 Query rollback
308 Query SET autocommit=1
hibernate.cfg.xml excerpt:
<hibernate-configuration>
<!-- a SessionFactory instance listed as /jndi/name -->
<session-factory>
<!-- properties -->
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="show_sql">false</property>
<property name="use_outer_join">false</property>
<property name="transaction.manager_lookup_class">org.hibernate.transaction.JBossTransactionManagerLookup</property>
<property name="transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>
<property name="jta.UserTransaction">UserTransaction</property>
<property name="connection.username">remon</property>
<property name="connection.password">re2005</property>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://localhost:3306/jn_head</property>
<property name="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</property>
<property name="hibernate.connection.release_mode">on_close</property>
<property name="hibernate.connection.autocommit">false</property>
<property name="hibernate.cache.use_second_level_cache">false</property>
<property name="hibernate.cache.use_query_cache">false</property>
<property name="hibernate.jdbc.use_scrollable_resultset">false</property>
<property name="hibernate.jdbc.batch_size">0</property>
<property name="hibernate.jdbc.fetch_size">0</property>
<!-- mapping files -->
. . . [removed]
</session-factory>
</hibernate-configuration>
|