ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jeff Butler" <jeffgbut...@gmail.com>
Subject Re: execution of nested result maps depends on number of mapped properties?
Date Thu, 23 Oct 2008 12:41:17 GMT
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.

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;
>    }
> }
>
> Ingmar
>

Mime
View raw message