Starting transaction after open connection
------------------------------------------
Key: IBATISNET-201
URL: http://issues.apache.org/jira/browse/IBATISNET-201
Project: iBatis for .NET
Issue Type: Bug
Components: DataMapper
Affects Versions: DataMapper 1.5.1
Environment: Windows XP SP2, SQLEXPRESS
Reporter: Bill Sorensen
Priority: Minor
I'm running into problems with disposing of a session. I'd like to keep a
connection open for an extended period, and occasionally run transactions in
it. If I write my code as follows:
using (IDalSession session = Mapper.Instance().OpenConnection())
{
Mapper.Instance().LocalSession.BeginTransaction(false);
// do stuff
Mapper.Instance().LocalSession.CommitTransaction(false);
}
The code blows up when the using block ends:
System.InvalidOperationException: This SqlTransaction has completed; it is no
longer usable.
at System.Data.SqlClient.SqlTransaction.ZombieCheck()
at System.Data.SqlClient.SqlTransaction.Rollback()
at IBatisNet.DataMapper.SqlMapSession.RollBackTransaction()
at IBatisNet.DataMapper.SqlMapper.RollBackTransaction()
at IBatisNet.DataMapper.SqlMapSession.Dispose()
This is a simplified example - the final code would have try..catch and
multiple transactions over time (not nested).
My workaround is to call OpenConnection() and CloseConnection() explicitly, and
avoid the using block.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira