[
https://issues.apache.org/jira/browse/IBATISNET-221?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Gilles Bayon closed IBATISNET-221.
----------------------------------
Resolution: Duplicate
Resolve in IBATISNET-242
> 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.