You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ibatis.apache.org by "Jeff Butler (JIRA)" <ib...@incubator.apache.org> on 2006/06/08 23:06:34 UTC

[jira] Commented: (IBATIS-225) Reuse resultmap for single bean property

    [ http://issues.apache.org/jira/browse/IBATIS-225?page=comments#action_12415427 ] 

Jeff Butler commented on IBATIS-225:
------------------------------------

I propose to fix this using Paul's last suggestion - meaning that if the specified property is not a collection, then we'll just create and populate the value.  We'll still use the resultMap attribute, but we'll interpret it differently depending on whether the specified property is a Collection or not.  This will make it possible to reuse result maps for 1:1 mappings.

I've done some testing of my proposed fix with and without the groupBy attribute specified and I'm getting the results I expect in each case.

BTW - resultMap really does what it means - it reuses a resultMap.  There was just an assumption that resultMap would only be used in conjunction with groupBy and that the property would always be some kind of collection.  This fix will remove that assumption.

A good side effect of this fix is that you will be able to provide custom List, Set, or Collection implementations through the result object factory if you so desire (this has come up recently on the user list).


> Reuse resultmap for single bean property
> ----------------------------------------
>
>          Key: IBATIS-225
>          URL: http://issues.apache.org/jira/browse/IBATIS-225
>      Project: iBatis for Java
>         Type: Improvement

>   Components: SQL Maps
>     Reporter: Huy Do
>     Assignee: Jeff Butler

>
> Allow the following reuse of result maps
> <resultMap id="Pick" class="package.domain.Pick">
>   <result property="pickId" column="pick_id"/>
>    <result property="sale" resultMap="Sale"/>
> </resultMap>
> <resultMap id="Sale" class="Sale">
>    <result column="sale_id" property="saleId"/>
> </resultMap>
> with beans
> class Pick {
>       String pickId;
>       Sale sale;
> }
> class Sale {
>       String saleId;
> }
> At the moment <result property="sale" resultMap="Sale"/> can only be reused if property "sale" is a collection.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira