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 "Chick, Brian" <Br...@qg.com> on 2007/05/15 21:41:53 UTC

GroupBy & Constructors

 I'm trying to use the groupBy attribute in conjunction with a
constructor.  When using the groupBy attribute with the default no-args
constructor, it works great.  Having issues using it when specifing a
constructor.  My resultmap that looks like this:

<resultMap id="ResultId" class="ResultClass" groupBy="TheUniqueId">
    <constructor>
        <argument argumentName="inUniqueId" column="ID"
dbType="Integer"/>        
        <argument argumentName="inValOne" column="VAL_ONE"
dbType="string"/>   
        <argument argumentName="inValTwo" column="VAL_TWO"
dbType="string"/>
    </constructor>
    <result property="TheUniqueId" column ="ID" dbType ="Integer"/>
    <result property ="ChildObject"
resultMapping="Domain.DataAccess.SqlMaps.ChildMapping"/>
</resultMap>

Throws the following NullReferenceException:

System.NullReferenceException was unhandled by user code
  Message="Object reference not set to an instance of an object."
  Source="IBatisNet.DataMapper"
  StackTrace:
       at
IBatisNet.DataMapper.MappedStatements.BaseStrategy.GetUniqueKey(IResultM
ap resultMap, RequestScope request, IDataReader reader)
       at
IBatisNet.DataMapper.MappedStatements.ResultStrategy.GroupByStrategy.Pro
cess(RequestScope request, IDataReader& reader, Object resultObject)
       at
IBatisNet.DataMapper.MappedStatements.ResultStrategy.MapStrategy.Process
(RequestScope request, IDataReader& reader, Object resultObject)
       at
IBatisNet.DataMapper.MappedStatements.MappedStatement.RunQueryForList[T]
(RequestScope request, ISqlMapSession session, Object parameterObject,
IList`1 resultObject, RowDelegate`1 rowDelegate)
       at
IBatisNet.DataMapper.MappedStatements.MappedStatement.ExecuteQueryForLis
t[T](ISqlMapSession session, Object parameterObject)
       at IBatisNet.DataMapper.SqlMapper.QueryForList[T](String
statementName, Object parameterObject)
       at
Quad.App.DataAccess.IBatis.BaseDataSource.<>c__DisplayClass59`1.<QueryFo
rList>b__58()
	 . . .

Any ideas would be appreciated.  Thanks.

RE: GroupBy & Constructors

Posted by "Chick, Brian" <Br...@qg.com>.
Oh well, thanks for the quick feedback.   

-----Original Message-----
From: Bob Hanson [mailto:mnbob70@gmail.com] 
Sent: Tuesday, May 15, 2007 2:55 PM
To: user-cs@ibatis.apache.org
Subject: Re: GroupBy & Constructors

Unfortunately GroupBy result maps do not currently support the
constructor element.

On 5/15/07, Chick, Brian <Br...@qg.com> wrote:
>  I'm trying to use the groupBy attribute in conjunction with a 
> constructor.  When using the groupBy attribute with the default 
> no-args constructor, it works great.  Having issues using it when 
> specifing a constructor.  My resultmap that looks like this:
>
> <resultMap id="ResultId" class="ResultClass" groupBy="TheUniqueId">
>     <constructor>
>         <argument argumentName="inUniqueId" column="ID"
> dbType="Integer"/>
>         <argument argumentName="inValOne" column="VAL_ONE"
> dbType="string"/>
>         <argument argumentName="inValTwo" column="VAL_TWO"
> dbType="string"/>
>     </constructor>
>     <result property="TheUniqueId" column ="ID" dbType ="Integer"/>
>     <result property ="ChildObject"
> resultMapping="Domain.DataAccess.SqlMaps.ChildMapping"/>
> </resultMap>
>
> Throws the following NullReferenceException:
>
> System.NullReferenceException was unhandled by user code
>   Message="Object reference not set to an instance of an object."
>   Source="IBatisNet.DataMapper"
>   StackTrace:
>        at
> IBatisNet.DataMapper.MappedStatements.BaseStrategy.GetUniqueKey(IResul
> tM ap resultMap, RequestScope request, IDataReader reader)
>        at
> IBatisNet.DataMapper.MappedStatements.ResultStrategy.GroupByStrategy.P
> ro cess(RequestScope request, IDataReader& reader, Object 
> resultObject)
>        at
> IBatisNet.DataMapper.MappedStatements.ResultStrategy.MapStrategy.Proce
> ss (RequestScope request, IDataReader& reader, Object resultObject)
>        at
> IBatisNet.DataMapper.MappedStatements.MappedStatement.RunQueryForList[
> T] (RequestScope request, ISqlMapSession session, Object 
> parameterObject,
> IList`1 resultObject, RowDelegate`1 rowDelegate)
>        at
> IBatisNet.DataMapper.MappedStatements.MappedStatement.ExecuteQueryForL
> is t[T](ISqlMapSession session, Object parameterObject)
>        at IBatisNet.DataMapper.SqlMapper.QueryForList[T](String
> statementName, Object parameterObject)
>        at
> Quad.App.DataAccess.IBatis.BaseDataSource.<>c__DisplayClass59`1.<Query
> Fo
> rList>b__58()
>          . . .
>
> Any ideas would be appreciated.  Thanks.
>

Re: GroupBy & Constructors

Posted by Bob Hanson <mn...@gmail.com>.
Unfortunately GroupBy result maps do not currently support the
constructor element.

On 5/15/07, Chick, Brian <Br...@qg.com> wrote:
>  I'm trying to use the groupBy attribute in conjunction with a
> constructor.  When using the groupBy attribute with the default no-args
> constructor, it works great.  Having issues using it when specifing a
> constructor.  My resultmap that looks like this:
>
> <resultMap id="ResultId" class="ResultClass" groupBy="TheUniqueId">
>     <constructor>
>         <argument argumentName="inUniqueId" column="ID"
> dbType="Integer"/>
>         <argument argumentName="inValOne" column="VAL_ONE"
> dbType="string"/>
>         <argument argumentName="inValTwo" column="VAL_TWO"
> dbType="string"/>
>     </constructor>
>     <result property="TheUniqueId" column ="ID" dbType ="Integer"/>
>     <result property ="ChildObject"
> resultMapping="Domain.DataAccess.SqlMaps.ChildMapping"/>
> </resultMap>
>
> Throws the following NullReferenceException:
>
> System.NullReferenceException was unhandled by user code
>   Message="Object reference not set to an instance of an object."
>   Source="IBatisNet.DataMapper"
>   StackTrace:
>        at
> IBatisNet.DataMapper.MappedStatements.BaseStrategy.GetUniqueKey(IResultM
> ap resultMap, RequestScope request, IDataReader reader)
>        at
> IBatisNet.DataMapper.MappedStatements.ResultStrategy.GroupByStrategy.Pro
> cess(RequestScope request, IDataReader& reader, Object resultObject)
>        at
> IBatisNet.DataMapper.MappedStatements.ResultStrategy.MapStrategy.Process
> (RequestScope request, IDataReader& reader, Object resultObject)
>        at
> IBatisNet.DataMapper.MappedStatements.MappedStatement.RunQueryForList[T]
> (RequestScope request, ISqlMapSession session, Object parameterObject,
> IList`1 resultObject, RowDelegate`1 rowDelegate)
>        at
> IBatisNet.DataMapper.MappedStatements.MappedStatement.ExecuteQueryForLis
> t[T](ISqlMapSession session, Object parameterObject)
>        at IBatisNet.DataMapper.SqlMapper.QueryForList[T](String
> statementName, Object parameterObject)
>        at
> Quad.App.DataAccess.IBatis.BaseDataSource.<>c__DisplayClass59`1.<QueryFo
> rList>b__58()
>          . . .
>
> Any ideas would be appreciated.  Thanks.
>