Hi, I personally encountered this issue several times either in 1.6.0 or 1.6.1. There were several archived discussion for this issue. The reason is when you create the DataMapper instance, the Ibatis.Net will see if the thread (which run the code to create the DataMapper) has the so called "HttpContext". If so the Ibatis.net will use that context as the session store, otherwise it will use the thread's context (not exactly true, but you can read the source code if you want). So when you do the multithreading, definitely you will use new thread not directly run this ASP.NET code so DataMapper cannot get its session store from the thread. So I have two solutions for this issue
1. Every time you call the DataMapper, get a new instance rather than the traditional singleton solution. This is very simple, do not need to change your code too much, but with bad performance, especially when you have a log of DB calls. 2. Change the code you creating the DataMapper instance, create a new thread to create that to force Ibatis.Net do not use the HttpContext. Hope this helps! Chen -----Original Message----- From: jmsandy [mailto:jmsa...@gmail.com] Sent: Wednesday, August 12, 2009 8:45 AM To: user-cs@ibatis.apache.org Subject: Help in MultiThreads Hi, I need much help from you. I need to optimize a query and the only possible way and run parallel accesses. I am consulting divided into parts to run. The scenario I have is: 1) I make the call to a Webservice which routines should be run. 2) I did call and got error with Threads. 3) I tried with asynchronous methods and got error. 4) The error I am getting is: Message="WebSessionStore: Could not obtain reference to HttpContext" Source="IBatisNet.DataMapper" StackTrace: at IBatisNet.DataMapper.SessionStore.WebSessionStore.ObtainSessionContext() at IBatisNet.DataMapper.SessionStore.WebSessionStore.get_LocalSession() at IBatisNet.DataMapper.SqlMapper.QueryForList[T](String statementName, Object parameterObject) How do I make several simultaneous queries in Ibatis. Please pass me an example. Thanks. -- View this message in context: http://www.nabble.com/Help-in-MultiThreads-tp24936820p24936820.html Sent from the iBATIS - User - Cs mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: user-cs-unsubscr...@ibatis.apache.org For additional commands, e-mail: user-cs-h...@ibatis.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: user-cs-unsubscr...@ibatis.apache.org For additional commands, e-mail: user-cs-h...@ibatis.apache.org