You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-cs@ibatis.apache.org by Martin Wickman <ma...@dapresy.com> on 2009/05/10 15:50:37 UTC
How to handle "value" property name?
Hello
I had some problems with a particual resultMap:
<resultMap id="a" class="Foo">
<result property="value" column="x" />
...
This gives me a stacktrace with NullReferenceException: "Object Reference not set to an instance of an object":
at IBatisNet.DataMapper.DataExchange.DotNetObjectDataExchange.SetData(Object& target, ResultProperty mapping, Object dataBaseValue) in C:\temp\ibatis-source-revision-513437\source-revision-513437\IBatisNet.DataMapper\DataExchange\DotNetObjectDataExchange.cs:line 95
...
After some digging I found that IBatisNet.DataMapper.Configuration.ResultMapping.ResultProperty::Initialize() has some extra logic for handling when the property attribute is "value" (line 379 in ResultProperty.cs), which makes it impossible to use "value" as property name.
if ( _propertyName.Length>0 &&
_propertyName != "value" &&
!typeof(IDictionary).IsAssignableFrom(resultClass) )
{
I changed my property to something else than "value" to avoid this. Could not find anything about it in the docs.