-->
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.  [ 3 posts ] 
Author Message
 Post subject: tranasaction with an exception doesnt rollback properly
PostPosted: Tue Nov 29, 2005 5:29 pm 
Newbie

Joined: Tue Nov 29, 2005 4:44 pm
Posts: 2
I am trying to persist a new class that contains some associations. The save is wrapped in a transaction using the Spring Framework HibernateTransactionManager. However the problem I'm having seems to be with hibernate.

When I try to persist the new class the first action in the queue is flushed as normal. When the next object which is an association of the first class that was persisted is flushed there is an exception and so hibernate rollbacks as it should. However the first object inserted in the transaction is not rolled back, it is persisted in the database. It looks like there is some its auto committing going on but I thought hibernate turned off auto commit at the start of a transaction. Anyone have any ideas?


Btw I am using c3p0 for database pooling on a oracle database.

Thanks,
T.J


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 29, 2005 5:41 pm 
Senior
Senior

Joined: Mon Apr 04, 2005 8:04 am
Posts: 128
Location: Manchester, NH USA
NO - this is a common misconception. Please look at the JavaDoc related to FlushMode. The semantics you want are probably to set FlushMode.COMMIT on your session upon retrieval of the session. I don't remember the API of spring well enough, but this is probably something you can set up when you're setting up the HibernateTransactionManager bean.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 29, 2005 7:15 pm 
Newbie

Joined: Tue Nov 29, 2005 4:44 pm
Posts: 2
Thanks for your response.

This is probably a very basic question but shouldnt a session last for the entire duration of a transaction and all connections used in that session have auto commit turned off. The session is then committed at the end of the transaction so any exception before the commit is rolled back properly. Is my understanding of transactions wrong?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.