BeginTransaction : Open a conenction & begin a transaction so all is normal

 
On 8/25/05, David Marzo (Puzzlet) <[EMAIL PROTECTED]> wrote:

I Have this scenarios that works ok:

       daoManager.BeginTransaction();
       daoManager.CommitTransaction ();

       daoManager.BeginTransaction();
       daoManager.RollBackTransaction();

       daoManager.OpenConnection();
       daoManager.CloseConnection();

But this fail

1) daoManager.OpenConnection ();
2) daoManager.BeginTransaction();
3) daoManager.CommitTransaction(false);
4) daoManager.CloseConnection();

With this Exception

IBatisNet.DataAccess.Exceptions.DataAccessException : DaoManager could
not invoke BeginTransaction(). A DaoSession is already started. Call
CommitTransaction() or RollbackTransaction first.

In line 2

I check the source code and I found in IBatisNet.DataMapper.SqlMapper

/// <summary>
/// Begins a database transaction.
/// </summary>
public IDalSession BeginTransaction()
{
       if (_sessionHolder.LocalSession != null)
       {
        throw new DataMapperException(
       "SqlMap could not invoke BeginTransaction(). A Transaction is
        already started. Call CommitTransaction() or
RollbackTransaction
         first.");
       }
//...///

Is a bug, test for session instead for open transaction, or I missing
some piece of the puzzle.

In ADO.NET this scenario works

IdbConnection connection = <new connection>;
connection.Open()
IdbCommand cmdA = connection.CreateCommand ();
<execute cmdA>
IdbTransaction transaction = connection.BeginConnection();
IdbCommand cmdB = transaction.Connection.CreateCommand();
<execute cmdB>
transaction.Commint()
connection.Close();


Thanks in advance

Un saludo:

David Marzo






Reply via email to