-->
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.  [ 8 posts ] 
Author Message
 Post subject: Transaction bug?
PostPosted: Thu Sep 22, 2005 5:50 am 
The follow code illustrate the problem:
Code:
// Use transaction first
t = session.BeginTransaction();
...
t.Commit();

// Don't use transaction
session.CreateQuery("From Test"); // <- ObjectDisposedException


It seems that in SessionImpl.AfterTransactionCompletion() didn't set transaction to null, so that my query will reuse a disposed transaction. I added transaction = null; and it works fine.

My I correct?


Top
  
 
 Post subject:
PostPosted: Thu Sep 22, 2005 6:16 am 
Newbie

Joined: Sun Sep 18, 2005 3:44 pm
Posts: 9
I got the same problem (I think), after transaction commit, any other query fails.
If I set transaction = null I get
"Cannot access a disposed object named 'AdoTransaction'"


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 22, 2005 7:13 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Yes, a bug slipped in and was already reported in JIRA, I'll fix it.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 26, 2005 5:56 pm 
Senior
Senior

Joined: Sat Sep 10, 2005 3:46 pm
Posts: 178
Is this fixed in the cvs version?


Top
 Profile  
 
 Post subject: Further issue with this change
PostPosted: Mon Sep 26, 2005 7:14 pm 
Newbie

Joined: Mon Jun 20, 2005 8:47 pm
Posts: 11
Hi,

As far as I can see, this renders the CurrentSession.Transaction.WasCommitted and CurrentSession.Transaction.WasRolledBack properties unusable after a committed or rolled back transaction has occurred.

"Object Reference not set to an instance of an object" because the transaction is disposed.

Not really sure whether these properties are useful anyway... Opinion?

Cheers,

Mike


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 27, 2005 7:08 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Ok I changed the fix so that those properties work again.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 17, 2006 3:12 pm 
Senior
Senior

Joined: Sat Sep 10, 2005 3:46 pm
Posts: 178
WasCommitted and WasRolledback seem to be of no value.

I have a transaction that failed and I want to rollback the transaction so I have this code

Code:
if(this._session.Transaction.WasRolledBack == false) {
               this._session.Transaction.Rollback();

}


but if I try to do the rollback I get this error:

This SqlTransaction has completed; it is no longer usable.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: This SqlTransaction has completed; it is no longer usable.

So what is the proper way to determine if I should do the rollback or if it has been done for me and the transaction is closed?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 20, 2006 7:53 pm 
Senior
Senior

Joined: Sat Sep 10, 2005 3:46 pm
Posts: 178
Sergey, Is this the expected behavior?


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