Transactions in IBatis.NET

146 views
Skip to first unread message

Jakub Malý

unread,
Oct 28, 2013, 12:51:47 PM10/28/13
to mybatis...@googlegroups.com

Hi, 

I am not sure how to work with transactions correctly

This is a working piece of code:

IDaoManager DaoManager = ... 
...
IDalSession dalSession = DaoManager.BeginTransaction();
DaoManager.CommitTransaction();
dalSession = DaoManager.BeginTransaction();

I thought this:

IDalSession dalSession = DaoManager.BeginTransaction();
dalSession.CommitTransaction();
dalSession = DaoManager.BeginTransaction();

But it throws DataAccessException: "DaoManager could not invoke BeginTransaction(). A DaoSession is already started. Call CommitTransaction() or RollbackTransaction first."

What is the difference between the two pieces? Is there a way to correctly commit when holding IDalSession and not DaoManager?

Also, what is the difference between IDalSession.Complete and IDalSession.CommitTransaction?

Reply all
Reply to author
Forward
0 new messages