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

Sven Boden commented on IBATIS-250:
-----------------------------------

Iwao,

The original version of the change worked, but there was a problem transcribing 
it to SVN. My fault, I didn't check. I will attach a patch to the current file 
in SVN to this JIRA issue, basically lines 561, 567, 568, 569 should be deleted 
and then it works as it should.

doNullMapping and getPrimitiveResultMappingValue have some duplicated 
functionality. Originally they were 1 method, the split was required so that 
the "null mapping" was separated out. Since you first have to check whether you 
have all nulls in the child result (to determine to make a child object or 
not), and only then apply the "null mapping" (else you never get all nulls). 

Your change does the duplication a third time, so I would actually like to have 
the patch above.

Iwoa, as short term fix can you try to use the patch I will upload to this 
issue.

Clinton, can this still be put in version 2.1.7.

Regards,
Sven

> CLONE -SELECT statement returns unexpected result when 'groupBy' and 
> 'nullValue' are specified in resultMaps.
> -------------------------------------------------------------------------------------------------------------
>
>          Key: IBATIS-250
>          URL: http://issues.apache.org/jira/browse/IBATIS-250
>      Project: iBatis for Java
>         Type: Bug
>   Components: SQL Maps
>     Versions: 2.1.5
>  Environment: PowerMac G5 1.8GHz dual, 2.25GB RAM, Mac OS X 10.4.2
> Using SqlMaps from tomcat via spring framework.
>     Reporter: Iwao AVE!
>     Assignee: Clinton Begin
>      Fix For: 2.1.7
>  Attachments: BasicResultMap.zip
>
> [Preparation]
> -- Database
> CREATE TABLE parent ( parentId, parentName );
> CREATE TABLE child ( childId, parentId, childName, childAge );
> INSERT INTO parent ( parentId, parentName ) VALUES ( 1, 'Mr Parent' );
> -- Java classes.
> public class Parent
> {
>    private int parentId;
>    private String parentName;
>    private List childList;
>    // accessor methods...
> }
> public class Child
> {
>    private int childId;
>    private String childName;
>    private int childAge;
>    // accessor methods...
> }
> --SqlMap.
> <sqlMap namespace="Family">
>    <resultMap id="parentResult" class="Parent" groupBy="parentId">
>       <result property="parentId" column="parentId"/>
>       <result property="parentName" column="parentName"/>
>      <result property="childList" resultMap="Family.childResult"/>
>    </resultMap>
>    <resultMap id="childResult" class="Child">
>       <result property="childId" column="childId"/>
>       <result property="childName" column="childName"/>
>       <result property="childAge" column="childAge" nullValue="0"/>
>    </resultMap>
>    <select id="getParent" resultMap="parentResult" parameterClass="int">
>       SELECT
>          parent.parentId, parent.parentName,
>          child.childId, child.childName, child.childAge
>       FROM parent
>          LEFT JOIN child ON parent.parentId = child.parentId
>       WHERE
>          parent.parentId = #value#
>    </select>
> </sqlMap>
> --
> [Test]
> Executing statement "getParent" with parameter '1'.
> [Expected result]
> Query returns 1 'Parent' object and 'childList' property of it is empty 
> (doesn't mean null).
> [Actual result]
> The 'childList' property of the returned 'Parent' contains 1 'Child' object.
> [Additional information]
> If 'nullValue' is not specified in 'childResult', it works as expected.
> But this, of course, causes an error if there is a row in the 'child' table 
> and the 'childAge' column is null.

-- 
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

Reply via email to