[ http://issues.apache.org/jira/browse/IBATISNET-104?page=comments#action_12360222 ]
Ron Grabowski commented on IBATISNET-104: ----------------------------------------- The offending code is most likely this snippet from SqlMapper.cs: if (session == null) { session = new SqlMapSession(this.DataSource); session.OpenConnection(); isSessionLocal = true; } IMappedStatement statement = GetMappedStatement(statementName); try { rows = statement.ExecuteUpdate(session, parameterObject); } catch { throw; } finally { if ( isSessionLocal ) { session.CloseConnection(); } } IMappedStatement fires the Execute event when a query has been executed. Perhaps this idea could be extended to include PreExecute and PostExecute events that would open and close the connection to the database if the underlying MappedStatement is used when there is a cache miss: // create an open a SqlMapSession statement.PreExecute(statement_PreExecute); // close SqlMapSession statement.PostExecute(statement_PostExecute); rows = statement.ExecuteUpdate(session, parameterObject); > QueryForXXX do not check cache before opening/closing connection > ---------------------------------------------------------------- > > Key: IBATISNET-104 > URL: http://issues.apache.org/jira/browse/IBATISNET-104 > Project: iBatis for .NET > Type: Wish > Components: DataMapper > Versions: DataMapper 1.2.1 > Reporter: H. E. Sum > Priority: Minor > > I was confused by SqlMapper opening and closing database connections even > when items were cached. I thought that it was fetching results from the > database, but when I looked at the source, it seemed like the QueryForXXX > methods are opening connections, calling MappedStatement to fetch results and > then closing connections. Perhaps opening/closing should be pushed to the > MappedStatement Class so connections are used only when there's a cache miss. -- 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