[ https://issues.apache.org/jira/browse/IBATISNET-214?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Gilles Bayon closed IBATISNET-214. ---------------------------------- Resolution: Fixed In SVN > Conflict on session access with multiple DAO contexts > ------------------------------------------------------ > > Key: IBATISNET-214 > URL: https://issues.apache.org/jira/browse/IBATISNET-214 > Project: iBatis for .NET > Issue Type: Bug > Components: DataAccess > Affects Versions: DataAccess 1.9 .1 > Reporter: Gilles Bayon > Assigned To: Gilles Bayon > Fix For: DataAccess 1.9 .2 > > > 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() > { > DomDaoManagerBuilder builder = new DomDaoManagerBuilder(); > builder.Configure("dao.config"); > IDaoManager mgr1 = DaoManager.GetInstance("Context1"); > IDaoManager mgr2 = DaoManager.GetInstance("Context2"); > IPatronDAO pDao = mgr1[typeof(IPatronDAO)] as IPatronDAO; > ILogDAO lDao = mgr2[typeof(ILogDAO)] as ILogDAO; > mgr1.OpenConnection(); > mgr2.OpenConnection(); <--- this is where the exception is > thrown > ... > mgr1.CloseConnection(); > mgr2.CloseConnection(); > } > 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. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.