Java Mailing List Archive

http://www.junlu.com/

Home » user-cs.ibatis »

IBatisNet.DataMapper.MappedStatements.PropertStrategy.GroupByStrategy throws NullReferenceException

Filin

2010-01-12


Author LoginPost Reply
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@(protected)
For additional commands, e-mail: user-cs-help@(protected)

©2008 junlu.com - Jax Systems, LLC, U.S.A.