Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
DataAccess 1.9 .1
-
None
Description
If I have multiple DAO contexts defined and attempt to open or start a
transaction on more than one context on the same thread I am receiving
the "session already option / transaction already started" exception. I
setup a test similar to the MultipleDAOTest in the iBATIS test cases
like so:
[Test]
public void TestMultipleDAO()
I traced this into the iBATIS source, and see that when the
DomDaoManagerBuilder creates a DaoManager instance
(DaoManager.NewInstance), the internal DaoManager constructor is
invoked, which immediately calls SessionStoreFactory with the DaoManager
id to create a session store. The problem appears to be that the call
to the SessionStoreFactory will always receive an empty string for id of
the Dao Context, since DomDaoManagerBuilder::GetContexts() doesn't
actually set the context id until after DaoManager.NewInstance()
returns. As a result, sessions for all contexts on the same thread are
keyed on the default string IBATIS_LOCAL_DAOSESSION from
AbstractSessionStore, which I confirmed through VS2005 debugging. As
soon as you create one session (openconnection or begintransaction), all
contexts' LocalDaoSession reference this session because the sessionName
is the same for all.