Uploaded image for project: 'iBatis for Java [READ ONLY]'
  1. iBatis for Java [READ ONLY]
  2. IBATIS-793

result rows are dropped because cacheKey ignores nested properties in ResultMap

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Won't Fix
    • 3.0 GA Candidate
    • None
    • Core
    • None

    Description

      NestedResultSetHandler does not take nested result map into account when creating cache keys. As a result, if the only columns that differ apply to nested properties, rows are dropped.

      NestedResultSetHandler.java:213
      private void createRowKeyForMappedProperties(ResultSet rs, CacheKey cacheKey, List<ResultMapping> resultMappings) {
      for (ResultMapping resultMapping : resultMappings) {
      if (resultMapping.getNestedQueryId() == null && resultMapping.getNestedResultMapId() == null) {
      final String column = resultMapping.getColumn();
      final TypeHandler th = resultMapping.getTypeHandler();
      if (column != null) {
      try {
      final Object value = th.getResult(rs, column);
      if (value != null)

      { cacheKey.update(column); cacheKey.update(value); }

      } catch (Exception e)

      { //ignore }

      }
      } /* ELSE PART MISSING*/
      }
      }

      This causes rows to be dropped.

      NestedResultSetHandler.java:59
      protected void handleRowValues(ResultSet rs, ResultMap resultMap, ResultHandler resultHandler, RowBounds rowBounds) throws SQLException {
      final DefaultResultContext resultContext = new DefaultResultContext();
      skipRows(rs, rowBounds);
      while (shouldProcessMoreRows(rs, resultContext, rowBounds)) {
      final ResultMap discriminatedResultMap = resolveDiscriminatedResultMap(rs, resultMap);
      final CacheKey rowKey = createRowKey(discriminatedResultMap, rs);
      final boolean knownValue = globalRowValueCache.containsKey(rowKey);
      Object rowValue = getRowValue(rs, discriminatedResultMap, rowKey);
      if (!knownValue)

      { /*THIS CHECK CAUSES THE ROW TO BE DROPPED IF ONLY NESTED COLUMNS ARE DIFFERENT*/ resultContext.nextResultObject(rowValue); resultHandler.handleResult(resultContext); }

      }
      }

      Attachments

        Activity

          People

            Unassigned Unassigned
            mofleury Marc-Olivier Fleury
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Issue deployment