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 11:37:15 GMT
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;
     }
}

Ingmar

Mime
View raw message