ibatis-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rogelio J. Baucells (JIRA)" <ibatis-...@incubator.apache.org>
Subject [jira] Commented: (IBATISNET-221) InvalidCastException while getting object out of the cache
Date Thu, 14 Jun 2007 13:42:27 GMT

    [ https://issues.apache.org/jira/browse/IBATISNET-221?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12504738

Rogelio J. Baucells commented on IBATISNET-221:

Yes, this workaround will work since it will use the Non-Generic method. I applied the original
fix to my code since the issue has not been fixed yet...

> InvalidCastException while getting object out of the cache
> ----------------------------------------------------------
>                 Key: IBATISNET-221
>                 URL: https://issues.apache.org/jira/browse/IBATISNET-221
>             Project: iBatis for .NET
>          Issue Type: Bug
>          Components: DataMapper
>    Affects Versions: DataMapper 1.6.1
>         Environment: IBatis.net SVN, revision 527493, .Net 2.0
>            Reporter: Rogelio J. Baucells
>            Priority: Critical
> There is a problem in the implementation of CachingStatement::ExecuteQueryForObject for
.Net2.0. The following scenario triggers the InvalidCastException:
> - Create a <ResultMap>, <procedure>, <parameterMap> and <cacheModel>
for a select statement.
> - Invoke the statement with parameters that does not return any results
> - Invoke the same statement again
> The first invocation will store a NULL_OBJECT in the cache for this key (CacheModel::this[CacheKey
key]), the second statement will retrieve the NULL_OBJECT from the cache and will cause the
InvalidCastException at:
> obj = (T)this.Statement.CacheModel[cacheKey];
> Also the next statement will never be TRUE since obj is of type T:
> if ((object)obj == CacheModel.NULL_OBJECT)
> The solution for this problem would be declaring obj as object and casting to T at the
time of returning from the method, something like:
> object obj = null;
> ...
> return (T)obj;

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message