ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ingmar Lötzsch <iloetz...@asci-systemhaus.de>
Subject Re: execution of nested result maps depends on number of mapped properties?
Date Thu, 23 Oct 2008 16:43:03 GMT
Thank you Jeff, for the information.

Jeff Butler schrieb:
> This is a known bug:
> 
> http://issues.apache.org/jira/browse/IBATIS-357
> http://issues.apache.org/jira/browse/IBATIS-450
> 
> Feel free to attach a patch if you've got one.

I think, my first idea, simply call ResultSet.wasNull() does not work. 
The column name attribute of the property element must be ignored in 
case of the presence of the resultMap attribute. Maybe it's correct to 
first apply the children and if any returns not null, then set foundData 
to true. But this is another algorithm.

> Jeff Butler
> 
> 
> On Thu, Oct 23, 2008 at 6:37 AM, Ingmar Lötzsch
> <iloetzsch@asci-systemhaus.de> wrote:
>> Hello,
>>
>> I found the reason for my problem is the following method in class
>> ResultMap, line 310:
>>
>>  public Object[] getResults(StatementScope statementScope, ResultSet rs)
>>      throws SQLException {
>> ...
>>    boolean foundData = false;
>>    Object[] columnValues = new Object[getResultMappings().length];
>>    for (int i = 0; i < getResultMappings().length; i++) {
>>      ResultMapping mapping = (ResultMapping) getResultMappings()[i];
>>      errorContext.setMoreInfo(mapping.getErrorString());
>>      if (mapping.getStatementName() != null) {
>> ...
>>        foundData = foundData || columnValues[i] != null;
>>      } else if (mapping.getNestedResultMapName() == null) {
>>        columnValues[i] = getPrimitiveResultMappingValue(rs, mapping);
>>        if (columnValues[i] == null) {
>>          columnValues[i] = doNullMapping(columnValues[i], mapping);
>>        } else {
>>          foundData = true;
>>        }
>>      }
>>    // TODO: add a check for the case
>>    // mapping.getNestedResultMapName() != null
>>    }
>>
>>    statementScope.setRowDataFound(foundData);
>>
>>    return columnValues;
>>  }
>>
>> The value of foundData remains false, if there are only mappings with nested
>> result maps. This proceeding assumes that there is no data in this case. But
>> this assumption seems to be wrong. For the nested result maps one have to
>> check, if ResultSet.wasNull() returns true, I think.
>>
>> else {
>>    // check the return value of ResultSet.wasNull()
>>    if (ResultSet.wasNull() has returned false) {
>>        foundDate = true;
>>    }
>> }

Mime
View raw message