-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Identity-insert and transaction rollback
PostPosted: Tue Aug 28, 2007 9:42 am 
Newbie

Joined: Tue Aug 28, 2007 8:43 am
Posts: 2
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.


Top
 Profile  
 
 Post subject: Re: Identity-insert and transaction rollback
PostPosted: Tue Aug 28, 2007 2:46 pm 
Beginner
Beginner

Joined: Mon Aug 27, 2007 8:10 am
Posts: 37
svartalfar wrote:
I have a question regarding Hibernate transaction rollback: does identity-insert participate in current transaction? If so, is it rolled back correctly with transaction?

Unfortunately, after transaction is rolled back, new row stays in nnn.i_a_sh.



AFAIK, this is not Hibernate behaviour, it is DBMS and all DBMS's I know do not rollback the incremented identity.


Top
 Profile  
 
 Post subject: Re: Identity-insert and transaction rollback
PostPosted: Wed Aug 29, 2007 3:37 am 
Newbie

Joined: Tue Aug 28, 2007 8:43 am
Posts: 2
hutorny wrote:

AFAIK, this is not Hibernate behaviour, it is DBMS and all DBMS's I know do not rollback the incremented identity.


Thanks for reading this, hutorny

Well. I do not mind if DMBS keeps the incremented identity after rollback. What troubles me is that insert statement data is kept in the database after rollback.[/i]


Top
 Profile  
 
 Post subject: Re: Identity-insert and transaction rollback
PostPosted: Tue Jun 23, 2009 1:14 am 
Newbie

Joined: Tue Jun 23, 2009 1:05 am
Posts: 1
I faced the same issue today: my insert statement did not rollback. On further investigation found that it was indeed DBMS issue. MySQL 5.x did not rollback if column of inserted row had auto increment set to true. If auto increment was removed rollback worked fine.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.