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.  [ 6 posts ] 
Author Message
 Post subject: WasCommitted value remains false after transaction.Commit()
PostPosted: Wed Jan 31, 2007 6:01 am 
Newbie

Joined: Wed Jan 31, 2007 5:26 am
Posts: 8
Location: Tel Aviv, Israel
I'm working with NHibernate 1.2 beta3, against an Oracle database and stumbled with what seems to be a bug with the WasCommitted flag (occurs in both ADO.NET providers).

This code will demonstrate the problem:

Code:
            transaction = session.BeginTransaction();
            transaction.Commit();
            Console.WriteLine(session.Transaction.WasCommitted.ToString());
            Console.WriteLine(transaction.WasCommitted.ToString());


Executing this code will print 'False' for the session.Transaction.WasCommitted and a desired 'True' for the transaction.WasCommitted.

This does not accure in NHibernate 1.0.3 version.


Top
 Profile  
 
 Post subject: Re: WasCommitted value remains false after transaction.Commi
PostPosted: Wed Jan 31, 2007 6:12 am 
Expert
Expert

Joined: Thu Jan 19, 2006 4:29 pm
Posts: 348
avissar wrote:
Executing this code will print 'False' for the session.Transaction.WasCommitted and a desired 'True' for the transaction.WasCommitted.


What if
Code:
if (session.Transaction != transaction)
  Console.WriteLine("new transaction started");


From ConnectionManager

Code:
      public ITransaction Transaction
      {
         get
         {
            if (transaction == null)
            {
               transaction = session.Factory.TransactionFactory.CreateTransaction(session);
            }
            return transaction;
         }
      }


Gert

_________________
If a reply helps You, rate it!


Top
 Profile  
 
 Post subject: Re: WasCommitted value remains false after transaction.Commi
PostPosted: Wed Jan 31, 2007 6:58 am 
Newbie

Joined: Wed Jan 31, 2007 5:26 am
Posts: 8
Location: Tel Aviv, Israel
gert wrote:

What if
Code:
if (session.Transaction != transaction)
  Console.WriteLine("new transaction started");




session.Transaction != transaction does evaluates true.
But even though a new transaction object is created, I don't think a new database transaction is opened.

This code results with exactly the same output:

Code:
transaction = session.BeginTransaction();
session.Transaction.Commit();
Console.WriteLine(session.Transaction.WasCommitted.ToString());
Console.WriteLine(transaction.WasCommitted.ToString());


But in any case this is odd behaviour, isn't it?

_________________
Tomer Avissar.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 31, 2007 7:04 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
I implemented it to match Hibernate3 behavior, and yes, this may be confusing. session.Transaction is the current transaction of the session. After a transaction is completed it is no longer considered current for the session, and the session creates a new ITransaction object. The new transaction is not started immediately though.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 31, 2007 7:13 am 
Beginner
Beginner

Joined: Mon Jan 08, 2007 11:59 pm
Posts: 31
I am confused with the usage of Session.Transaction.WasCommitted

When is this call useful, because as I see it, it will always return false.

Job Samuel


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 31, 2007 7:58 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
This will always return false, yes. But you can remember the original transaction somewhere and then originalTransaction.WasCommitted will return true or false depending on whether the transaction committed successfully.


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