-->
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: transaction question
PostPosted: Thu Nov 06, 2003 10:40 pm 
Newbie

Joined: Thu Nov 06, 2003 10:26 pm
Posts: 2
I have come across some behavoir with Hibernate transactions that I do not understand. I would expect a transaction rollback to invalidate a session.save, but it do not seem to. If I do the code below:

Session sess = factory.getSession();
Transaction tx = null;

try {
tx = s.beginTransaction();
MappedObject obj = new MappedObject();
sess.save( obj );
throw new Exception();
tx.commit();
}
catch (Exception e) {
tx.rollback();
throw e;
}
finally {
sess.close();
}

I end up with obj in the database. Now if obj was already in the database, and I am just updating a value, then the rollback works as expected.
Am I missing something? I assume a transaction rollback puts the database in the same state it was before the transaction started.

thanks,
-tao starbow


Top
 Profile  
 
 Post subject: Is 'auto commit' enabled on the JDBC connection?
PostPosted: Fri Nov 07, 2003 12:37 am 
Contributor
Contributor

Joined: Thu Nov 06, 2003 9:49 pm
Posts: 104
Location: New York, NY
Just a thought...


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 07, 2003 4:03 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
I hope you are not using MySQL with out the InnoDB tables enabled?

If you are transaction don't work correctly. Otherwise more information please.


Top
 Profile  
 
 Post subject: No InnoDB tables...
PostPosted: Fri Nov 07, 2003 7:46 pm 
Newbie

Joined: Thu Nov 06, 2003 10:26 pm
Posts: 2
That's it! I thought I was using them, but I am not.
Thanks for answering a doppy question & saving me more time banging my head on the wall.

-tao


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.