-->
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.  [ 5 posts ] 
Author Message
 Post subject: Rollback errors
PostPosted: Thu Jul 08, 2004 5:35 am 
Newbie

Joined: Fri May 07, 2004 6:05 am
Posts: 17
To put it in a simple way, I suspect there is a bug in the way rollbacks are implemented

First of all, we are not building a web app, but a normal application. Hence we need to have what we could call transcient objects.

Our first try was to assign one Session by user, and have this Session last all the application running time - ie we are NOT in the one Session per Transaction paradigm. I insist on this point, because I know people are going to answer that (and it's also said in te doc) a Session should be closed as soon as possible after a rollback. This is simply not what I'm trying to do here. It might be a school case, but still there is a real problem here.

s = sf.openSession();

for (int comptCommandeClient = 0; comptCommandeClient < 8; comptCommandeClient++) {

try {
System.out.println ("SESSION.CONNECTION = " + s.connection());
Transaction t = s.beginTransaction ();

tpCommande comm = new tpCommande ();
comm.setLibelle("temporaire_" + comptClient);

if ((comptCommandeClient % 2) == 0) {
t.commit ();
} else {
t.rollback ();
System.out.println ("### ROLLBACK !!!");
}

System.out.println ("Etat du commit : " + t.wasCommitted());
System.out.println ("Etat du rollback : " + t.wasRolledBack());


} catch (Exception cce) {
cce.printStackTrace();
}
s.close ();


The database is Postgres 7.4, and there is a c3p0 pool (but the problem also exists without pooling)

After running this code, the first seven records are written in the DB, and only the last one was really ignored, when all the odds should have been rolled back.

As I understand it, after making a whole day of diff


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 08, 2004 5:39 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
You are using the Session and Transaction wrong. My advice is to read chapter 5 of Hibernate in Action. There is nothing broken in Hibernate.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject: precision
PostPosted: Thu Jul 08, 2004 5:42 am 
Newbie

Joined: Fri May 07, 2004 6:05 am
Posts: 17
By the way, after a rollback

- when not using connection pooling,
Transaction.wasCommited = false
Transaction.wasRolledBack () = true

- when using c3p0 pooling
Transaction.wasCommited = false
Transaction.wasRolledBack () = false

wasRolledBack is true when the transac has actually been rolledback, and false when it was marked for rollback but has not been yet, according to the documentation

I don't know it is of any importance


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 08, 2004 5:49 am 
Newbie

Joined: Fri May 07, 2004 6:05 am
Posts: 17
Hi Christian

aren't we supposed to be in a hibernate users forum ? Because your reply makes me think you're just advertising your book, which surely won't help me to solve our problem here today


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 08, 2004 5:50 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
I'm sorry if you have that impression. Read it anyway.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


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