ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Medium <contactm...@gmail.com>
Subject Re: Reusing resultmap for nested object
Date Fri, 18 Nov 2005 12:23:31 GMT
Hi Jeff,

Thanks for the clarification. I have filed a jira request (IBATIS-225)

Anyone who may find this useful, please vote for it.

Huy

Jeff Butler wrote:

> I believe this is because reusing result maps is a feature of the 
> "groupBy" function, and iBATIS assumes the property will be a 
> Collection of some kind.  So, the real answer is that you can reuse 
> result maps if your properties are collections.  Otherwise not.
>  
> I'm not sure if this is an oversight or "by design" - but it probably 
> should be fixed/enhanced.  You could file a JIRA request to help us 
> remember.
>  
> Jeff Butler
>  
> On 11/17/05, *Medium* <contactme42@gmail.com 
> <mailto:contactme42@gmail.com>> wrote:
>
>     I tried this, but get the following error. I am using the java version
>     2.1.6.589 (Sorry about the long trace). Hoping someone can shed some
>     light on this.
>
>     Thanks.
>
>     Huy
>
>
>     My map is below:
>
>
>     <sqlMap namespace="Pick">
>     <resultMap id="pickResultMap" class="package.domain.Pick">
>        <result column="pick_id" property="pickId"/>
>        <result column="pick_ref" property="pickRef"/>
>     </resultMap>
>     <resultMap id="pickJoined" class="package.domain.Pick"
>     extends="pickResultMap">
>        <result property="sale" resultMap="Sale.Sale"/>
>     </resultMap>
>     </sqlMap>
>
>     <sqlMap namespace="Sale">
>     <typeAlias alias="Sale" type=" openlink.domain.Sale"/>
>     <resultMap id="Sale" class="Sale">
>        <result column="sale_id" property="saleId"/>
>     </resultMap>
>     </sqlMap>
>
>     org.springframework.jdbc.UncategorizedSQLException: (SqlMapClient
>     operation): encountered SQLException [
>     --- The error occurred in openlink/dao/ibatis/maps/Pick.xml.
>     --- The error occurred while applying a result map.
>     --- Check the Pick.pickJoined.
>     --- The error happened while setting a property on the result object.
>     --- Cause: com.ibatis.sqlmap.client.SqlMapException: Error
>     instantiating
>     collection property for mapping 'sale'.  Cause:
>     java.lang.ClassCastException
>     Caused by: java.lang.ClassCastException]; nested exception is
>     com.ibatis.common.jdbc.exception.NestedSQLException:
>     --- The error occurred in openlink/dao/ibatis/maps/Pick.xml.
>     --- The error occurred while applying a result map.
>     --- Check the Pick.pickJoined.
>     --- The error happened while setting a property on the result object.
>     --- Cause: com.ibatis.sqlmap.client.SqlMapException: Error
>     instantiating
>     collection property for mapping 'sale'.  Cause:
>     java.lang.ClassCastException
>     Caused by: java.lang.ClassCastException
>     com.ibatis.common.jdbc.exception.NestedSQLException:
>     --- The error occurred in openlink/dao/ibatis/maps/Pick.xml.
>     --- The error occurred while applying a result map.
>     --- Check the Pick.pickJoined.
>     --- The error happened while setting a property on the result object.
>     --- Cause: com.ibatis.sqlmap.client.SqlMapException: Error
>     instantiating
>     collection property for mapping 'sale'.  Cause:
>     java.lang.ClassCastException
>     Caused by: java.lang.ClassCastException
>     Caused by: com.ibatis.sqlmap.client.SqlMapException: Error
>     instantiating
>     collection property for mapping 'sale'.  Cause:
>     java.lang.ClassCastException
>     Caused by: java.lang.ClassCastException
>        at
>     com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWithCallback(GeneralStatement.java:188)
>        at
>
>
>
>     Gilles Bayon wrote:
>
>     > This syntax
>     > <resultMap id="product">
>     > <result property="id" column="PRD_ID"/>
>     > <result property="description" column="PRD_DESCRIPTION"/>
>     > <result property="category" resultMap="category">
>     > </resultMap>
>     >
>     > is supported .
>     >
>     >
>     > On 11/16/05, *Medium* < contactme42@gmail.com
>     <mailto:contactme42@gmail.com>
>     > <mailto:contactme42@gmail.com <mailto:contactme42@gmail.com>>>
>     wrote:
>     >
>     >     Hi,
>     >
>     >     Is there a way to reuse a resultmap for a nested object ?
>     >
>     >     I know how to map it as specified by the docs but its
>     getting a bit
>     >     unwieldly with all the repetition.
>     >
>     >     Docs:
>     >     <resultMap>
>     >     <result property="id" column="PRD_ID"/>
>     >     <result property="description" column="PRD_DESCRIPTION"/>
>     >     <result property="category.id <http://category.id>"
>     column="CAT_ID" />
>     >     <result property="category.description"
>     column="CAT_DESCRIPTION" />
>     >     </resultMap>
>     >
>     >     Goal:
>     >     <resultMap id="product">
>     >     <result property="id" column="PRD_ID"/>
>     >     <result property="description" column="PRD_DESCRIPTION"/>
>     >     <result property="category" resultMap="category">
>     >     </resultMap>
>     >
>     >     <resultMap id="category">
>     >     <result property="id" column="CAT_ID"/>
>     >     <result property="description" column="CAT_DESCRIPTION"/>
>     >     </resultMap>
>     >
>     >     Any help would be greatly appreciated. A simple yah or nah would
>     >     do fine
>     >     as well.
>     >
>     >     Thanks
>     >
>     >     Huy
>     >
>     >
>
>


Mime
View raw message