You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ibatis.apache.org by "Ron Grabowski (JIRA)" <ib...@incubator.apache.org> on 2005/05/09 19:22:10 UTC
[jira] Commented: (IBATISNET-60) QueryForMap(string statementName, object parameterObject, string keyProperty, string valueProperty) not calling session.CloseConnection() correctly
[ http://issues.apache.org/jira/browse/IBATISNET-60?page=comments#action_64760 ]
Ron Grabowski commented on IBATISNET-60:
----------------------------------------
I pasted the example code in wrong. Both examples are of the corrected code. Here is the wrong code and corrected code:
// WRONG
try
{
map = statement.ExecuteQueryForMap(session, parameterObject, keyProperty, valueProperty);
}
catch
{
if ( isSessionLocal )
{
session.CloseConnection();
}
throw;
}
// CORRECT
try
{
map = statement.ExecuteQueryForMap(session, parameterObject, keyProperty, valueProperty);
}
catch
{
throw;
}
finally
{
if ( isSessionLocal )
{
session.CloseConnection();
}
}
> QueryForMap(string statementName, object parameterObject, string keyProperty, string valueProperty) not calling session.CloseConnection() correctly
> ---------------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: IBATISNET-60
> URL: http://issues.apache.org/jira/browse/IBATISNET-60
> Project: iBatis for .NET
> Type: Bug
> Reporter: Ron Grabowski
> Assignee: Gilles Bayon
>
> As of 5/9/2005, the version of IBatisNet.DataMapper.SqlMapper.cs in source control contains the following code:
> public IDictionary QueryForMap(string statementName, object parameterObject, string keyProperty, string valueProperty)
> {
> bool isSessionLocal = false;
> IDalSession session = _sessionContainer.LocalSession;
> IDictionary map = null;
> if (session == null)
> {
> session = new SqlMapSession(this.DataSource);
> session.OpenConnection();
> isSessionLocal = true;
> }
> IMappedStatement statement = GetMappedStatement(statementName);
> try
> {
> map = statement.ExecuteQueryForMap(session, parameterObject, keyProperty, valueProperty);
> }
> catch
> {
> throw;
> }
> finally
> {
> if ( isSessionLocal )
> {
> session.CloseConnection();
> }
> }
> If ExecuteQueryForMap completes successfully and isSessionLocal is set to true, session.CloseConnection() is not called. The code should be changed as follows (to match the other QueryFor... methods):
> try
> {
> map = statement.ExecuteQueryForMap(session, parameterObject, keyProperty, valueProperty);
> }
> catch
> {
> throw;
> }
> finally
> {
> if ( isSessionLocal )
> {
> session.CloseConnection();
> }
> }
--
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