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

"select count(*) from table" return BigDecimal value in Oracle

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Invalid
    • 3.0 Beta 1
    • None
    • None
    • None

    Description

      User SqlSession.selectOne for the sql "select count from table" defined in mapping file should return Integer, but return BigDecimal in Oracle.

      The bug seems happen int DefaultResultSetHandler.mapResults method. There are codes below:

      ...
      for (int i = 1, n = rsmd.getColumnCount(); i <= n; i++) {
      boolean useLabel = mappedStatement.getConfiguration().isUseColumnLabel();
      String columnLabel = (useLabel ? rsmd.getColumnLabel : rsmd.getColumnName);
      columnLabel = columnLabel.toUpperCase();
      String propName = metaResultObject.findProperty(columnLabel);
      colSet.add(columnLabel);
      if (propName != null)

      { propSet.add(propName); Class javaType = metaResultObject.getSetterType(propName); // This line will return Object if the resultObject is PlatformTypeHolder TypeHandler typeHandler = typeHandlerRegistry.getTypeHandler(javaType); ResultMapping resultMapping = new ResultMapping.Builder(configuration, propName, columnLabel, typeHandler) .javaType(javaType).build(); autoMappings.put(propName, resultMapping); }

      }
      ...

      Maybe this bug can fixed by adding the code below after "Class javaType = metaResultObject.getSetterType(propName);"

      // -------------------------------------------------------------
      if((!rm.getType().isAssignableFrom(resultObject.getClass())&&(!rm.getType().isAssignableFrom(javaType))))
      javaType = rm.getType();
      // -------------------------------------------------------------

      Attachments

        Activity

          People

            Unassigned Unassigned
            torworx Yuan Tao
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Issue deployment