I have a question regarding Hibernate transaction rollback: does identity-insert participate in current transaction? If so, is it rolled back correctly with transaction?
I'm asking this because I've a strage situation with it. More technical details follow.
Hibernate version: 3.2
Hibernate settings:
hibernate.dialect = org.hibernate.dialect.MySQLInnoDBDialect
hibernate.show_sql = true
hibernate.generate_statistics = true
hibernate.bytecode.use_reflection_optimizer = true
hibernate.cache.use_query_cache = true
hibernate.cache.use_second_level_cache = false
hibernate.cache.provider_class = org.hibernate.cache.EhCacheProvider
hibernate.connection.autocommit = true
transaction.factory_class = org.hibernate.transaction.JDBCTransactionFactory
hibernate.cache.use_structured_entries = true
Name and version of the database you are using: mySQL Ver 14.12 Distrib 5.0.38
Here is the Hibernate Log:
Code:
[-------------]: [2007-08-28 16:14:23,671] DEBUG org.hibernate.transaction.JDBCTransaction - begin
[-------------]: [2007-08-28 16:14:23,673] DEBUG org.hibernate.transaction.JDBCTransaction - current autocommit status: true
[-------------]: [2007-08-28 16:14:23,674] DEBUG org.hibernate.transaction.JDBCTransaction - disabling autocommit
<...>
[-------------]: [2007-08-28 16:14:23,871] DEBUG org.hibernate.event.def.AbstractSaveEventListener - executing identity-insert immediately
[-------------]: [2007-08-28 16:14:23,872] DEBUG org.hibernate.cache.UpdateTimestampsCache - Pre-invalidating space [nnn.i_a_sh]
[-------------]: [2007-08-28 16:14:23,876] DEBUG org.hibernate.jdbc.AbstractBatcher - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
[-------------]: [2007-08-28 16:14:23,876] DEBUG org.hibernate.SQL - insert into nnn.i_a_sh (blabel_id, ad_id, sh_event_id, slabel_id, state) values (?, ?, ?, ?, ?)
[-------------]: [2007-08-28 16:14:24,226] DEBUG org.hibernate.id.IdentifierGeneratorFactory - Natively generated identity: 43
[-------------]: [2007-08-28 16:14:24,226] DEBUG org.hibernate.jdbc.AbstractBatcher - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
<...>
java.lang.NullPointerException
at <...>
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:296)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:177)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:144)
at org.springframework.orm.hibernate3.HibernateInterceptor.invoke(HibernateInterceptor.java:104)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:166)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy41.initiateShippingJob(Unknown Source)
at <...>.zzzJob.executeInternal(zzzJob.java:20)
at org.springframework.scheduling.quartz.QuartzJobBean.execute(QuartzJobBean.java:86)
at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:529)
[-------------]: [2007-08-28 16:14:25,022] DEBUG org.hibernate.transaction.JDBCTransaction - rollback
[-------------]: [2007-08-28 16:14:25,205] DEBUG org.hibernate.transaction.JDBCTransaction - re-enabling autocommit
[-------------]: [2007-08-28 16:14:25,380] DEBUG org.hibernate.transaction.JDBCTransaction - rolled back JDBC Connection
[-------------]: [2007-08-28 16:14:25,380] DEBUG org.hibernate.jdbc.ConnectionManager - transaction completed on session with on_close connection release mode; be sure to close the session to release JDBC resources!
[-------------]: [2007-08-28 16:14:25,380] DEBUG org.hibernate.cache.UpdateTimestampsCache - Invalidating space [nnn.i_a_sh], timestamp: 4867290174996480
[-------------]: [2007-08-28 16:14:25,381] DEBUG org.hibernate.impl.SessionImpl - disconnecting session
[-------------]: [2007-08-28 16:14:25,382] DEBUG org.hibernate.jdbc.ConnectionManager - releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
[-------------]: [2007-08-28 16:14:25,563] DEBUG org.hibernate.jdbc.ConnectionManager - transaction completed on session with on_close connection release mode; be sure to close the session to release JDBC resources!
Unfortunately, after transaction is rolled back, new row stays in nnn.i_a_sh.