Newbie | HibernateTransactionManager Rolling back Hibernate transaction

2 messages Options
Embed this post
Permalink
Anand Raman

Newbie | HibernateTransactionManager Rolling back Hibernate transaction

Reply Threaded More More options
Print post
Permalink
hi all,

A newbie issue has been bugging me.

I created a simple one to many relationship and have been trying to persist it to the database using appfuse archetyped project. Troop and Soldier classes are pretty straight forward with the following annotation to mark the association (directly copied from the hibernate annotation test cases).

However while running the test cases, Spring's HibernateTransactionManager is rolling back the transaction.

[timeflies] DEBUG [main] TroopDaoTest.startNewTransaction(392) | Began transaction (1): transaction manager [org.springframework.orm.hibernate3.HibernateTransactionManager@987197]; rollback [true].
[timeflies] DEBUG [main] TransactionSynchronizationManager.getResource(146) | Retrieved value [org.springframework.orm.hibernate3.SessionHolder@dc9766] for key [org.hibernate.impl.SessionFactoryImpl@bc5596] bound to thread [main]
[timeflies] DEBUG [main] TransactionSynchronizationManager.getResource(146) | Retrieved value [org.springframework.orm.hibernate3.SessionHolder@dc9766] for key [org.hibernate.impl.SessionFactoryImpl@bc5596] bound to thread [main]
[timeflies] DEBUG [main] HibernateTemplate.doExecute(410) | Found thread-bound Session for HibernateTemplate
[timeflies] DEBUG [main] SQL.log(401) | insert into Troop (id, name) values (null, ?)
[timeflies] DEBUG [main] SQL.log(401) | call identity()
[timeflies] DEBUG [main] SQL.log(401) | insert into Soldier (id, name, troop_fk) values (null, ?, ?)
[timeflies] DEBUG [main] SQL.log(401) | call identity()
[timeflies] DEBUG [main] SQL.log(401) | insert into Soldier (id, name, troop_fk) values (null, ?, ?)
[timeflies] DEBUG [main] SQL.log(401) | call identity()
[timeflies] DEBUG [main] HibernateTemplate.doExecute(435) | Not closing pre-bound Hibernate Session after HibernateTemplate
[timeflies] DEBUG [main] HibernateTransactionManager.triggerBeforeCompletion(893) | Triggering beforeCompletion synchronization
[timeflies] DEBUG [main] HibernateTransactionManager.processRollback(798) | Initiating transaction rollback
[timeflies] DEBUG [main] HibernateTransactionManager.doRollback(621) | Rolling back Hibernate transaction on Session [org.hibernate.impl.SessionImpl@19a8416]
[timeflies] DEBUG [main] HibernateTransactionManager.triggerAfterCompletion(922) | Triggering afterCompletion synchronization
[timeflies] DEBUG [main] TransactionSynchronizationManager.clearSynchronization(282) | Clearing transaction synchronization
[timeflies] DEBUG [main] TransactionSynchronizationManager.unbindResource(199) | Removed value [org.springframework.orm.hibernate3.SessionHolder@dc9766] for key [org.hibernate.impl.SessionFactoryImpl@bc5596] from thread [main]


The offending lines have been highlighted. I am not so sure why. The simple PersonDao test works all fine. Something fundamental is missing my eyes. Your insights would be helpful

Thanks
anand


--
Phone +91 98809 37073





---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Soldier.java (1K) Download Attachment
Troop.java (1K) Download Attachment
TroopDaoHibernate.java (602 bytes) Download Attachment
TroopDaoTest.java (1K) Download Attachment
mraible

Re: Newbie | HibernateTransactionManager Rolling back Hibernate transaction

Reply Threaded More More options
Print post
Permalink
This is the default behavior of AppFuse tests in that the data in the
database is reset to the state it started in.

This is because we subclass
AbstractTransactionalDataSourceSpringContextTests and it rolls back
transactions after ever test exists.

http://static.springsource.org/spring/docs/2.0.x/api/org/springframework/test/AbstractTransactionalDataSourceSpringContextTests.html

Matt

On Wed, Oct 14, 2009 at 4:05 AM, Anand Raman <[hidden email]> wrote:

> hi all,
>
> A newbie issue has been bugging me.
>
> I created a simple one to many relationship and have been trying to persist
> it to the database using appfuse archetyped project. Troop and Soldier
> classes are pretty straight forward with the following annotation to mark
> the association (directly copied from the hibernate annotation test cases).
>
> However while running the test cases, Spring's HibernateTransactionManager
> is rolling back the transaction.
>
> [timeflies] DEBUG [main] TroopDaoTest.startNewTransaction(392) | Began
> transaction (1): transaction manager
> [org.springframework.orm.hibernate3.HibernateTransactionManager@987197];
> rollback [true].
> [timeflies] DEBUG [main] TransactionSynchronizationManager.getResource(146)
> | Retrieved value [org.springframework.orm.hibernate3.SessionHolder@dc9766]
> for key [org.hibernate.impl.SessionFactoryImpl@bc5596] bound to thread
> [main]
> [timeflies] DEBUG [main] TransactionSynchronizationManager.getResource(146)
> | Retrieved value [org.springframework.orm.hibernate3.SessionHolder@dc9766]
> for key [org.hibernate.impl.SessionFactoryImpl@bc5596] bound to thread
> [main]
> [timeflies] DEBUG [main] HibernateTemplate.doExecute(410) | Found
> thread-bound Session for HibernateTemplate
> [timeflies] DEBUG [main] SQL.log(401) | insert into Troop (id, name) values
> (null, ?)
> [timeflies] DEBUG [main] SQL.log(401) | call identity()
> [timeflies] DEBUG [main] SQL.log(401) | insert into Soldier (id, name,
> troop_fk) values (null, ?, ?)
> [timeflies] DEBUG [main] SQL.log(401) | call identity()
> [timeflies] DEBUG [main] SQL.log(401) | insert into Soldier (id, name,
> troop_fk) values (null, ?, ?)
> [timeflies] DEBUG [main] SQL.log(401) | call identity()
> [timeflies] DEBUG [main] HibernateTemplate.doExecute(435) | Not closing
> pre-bound Hibernate Session after HibernateTemplate
> [timeflies] DEBUG [main]
> HibernateTransactionManager.triggerBeforeCompletion(893) | Triggering
> beforeCompletion synchronization
> [timeflies] DEBUG [main] HibernateTransactionManager.processRollback(798) |
> Initiating transaction rollback
> [timeflies] DEBUG [main] HibernateTransactionManager.doRollback(621) |
> Rolling back Hibernate transaction on Session
> [org.hibernate.impl.SessionImpl@19a8416]
> [timeflies] DEBUG [main]
> HibernateTransactionManager.triggerAfterCompletion(922) | Triggering
> afterCompletion synchronization
> [timeflies] DEBUG [main]
> TransactionSynchronizationManager.clearSynchronization(282) | Clearing
> transaction synchronization
> [timeflies] DEBUG [main]
> TransactionSynchronizationManager.unbindResource(199) | Removed value
> [org.springframework.orm.hibernate3.SessionHolder@dc9766] for key
> [org.hibernate.impl.SessionFactoryImpl@bc5596] from thread [main]
>
> The offending lines have been highlighted. I am not so sure why. The simple
> PersonDao test works all fine. Something fundamental is missing my eyes.
> Your insights would be helpful
>
> Thanks
> anand
>
>
> --
> Phone +91 98809 37073
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]