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 Filin <wF...@yandex.ru> on 2010/01/13 05:40:13 UTC

IBatisNet.DataMapper.MappedStatements.PropertStrategy.GroupByStrategy throws NullReferenceException

class AdvRecord
{
long Id;
int Year;
}

class Adv
{
long Id;
IList<AdvRecord> Records;
}

class Demand
{
long Id;
Adv Adv; //this property is not a IList!
}

<resultMap id="AdvRecordResult" class="AdvRecord">
<result property="Id" column="ADVR_ID" type="long" dbType="BigInt"/>
<result property="Year" column="ADVR_YEAR" type="int" dbType="Integer"/>
</resultMap>

<resultMap id="AdvResult" class="Adv" groupBy="Id">
<result property="Id" column="ADV_ID" type="long" dbType="BigInt"/>
<result property="Records" resultMapping="AdvRecordResult"/>
</resultMap>

<resultMap id="DemandResult" class="Demand">
<result property="Id" column="DMD_ID" type="long" dbType="BigInt"/>
<result property="Adv" resultMapping="AdvResult"/>
</resultMap>

in file IBatisNet.DataMapper.MappedStatements.PropertStrategy.GroupByStrategy

public object Get(RequestScope request, IResultMap resultMap, ResultProperty mapping, ref object target, IDataReader reader)
{
// The property is a IList --- Why???
IList list = null;

// Get the IList property
object property = ObjectProbe.GetMemberValue(target, mapping.PropertyName,
request.DataExchangeFactory.AccessorFactory);

if (property == null)// Create the list if need
{
property = mapping.ListFactory.CreateInstance(null); //here throw exception because ListFactory is null
mapping.SetAccessor.Set(target, property);
}
...
}

Why property with GroupByStrategy( Demand.Adv) must be IList? Can anybody suggest workaround?

---------------------------------------------------------------------
To unsubscribe, e-mail: user-cs-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-cs-help@ibatis.apache.org