[jira] Created: (IBATIS-620) "select count(*) from table" return BigDecimal value in Oracle

View: New views
3 Messages — Rating Filter:   Alert me  

[jira] Created: (IBATIS-620) "select count(*) from table" return BigDecimal value in Oracle

by JIRA ibatis-dev@incubator.apache.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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

                 Key: IBATIS-620
                 URL: https://issues.apache.org/jira/browse/IBATIS-620
             Project: iBatis for Java
          Issue Type: Bug
    Affects Versions: 3.0.0
            Reporter: Yuan Tao


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(i) : rsmd.getColumnName(i));
      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 (javaType.isAssignableFrom(rm.getType()))
        javaType = rm.getType();


--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@...
For additional commands, e-mail: dev-help@...


[jira] Commented: (IBATIS-620) "select count(*) from table" return BigDecimal value in Oracle

by JIRA ibatis-dev@incubator.apache.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


    [ https://issues.apache.org/jira/browse/IBATIS-620?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12739392#action_12739392 ]

Yuan Tao commented on IBATIS-620:
---------------------------------

The fix solution imported other bugs. so now, I have no idea to solve it.

Should I need convert the result SqlSession.selectOne to Integer manually.

> "select count(*) from table" return BigDecimal value in Oracle
> --------------------------------------------------------------
>
>                 Key: IBATIS-620
>                 URL: https://issues.apache.org/jira/browse/IBATIS-620
>             Project: iBatis for Java
>          Issue Type: Bug
>    Affects Versions: 3.0.0
>            Reporter: Yuan Tao
>
> 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(i) : rsmd.getColumnName(i));
>       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 (javaType.isAssignableFrom(rm.getType()))
>         javaType = rm.getType();

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@...
For additional commands, e-mail: dev-help@...


[jira] Closed: (IBATIS-620) "select count(*) from table" return BigDecimal value in Oracle

by JIRA ibatis-dev@incubator.apache.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


     [ https://issues.apache.org/jira/browse/IBATIS-620?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Clinton Begin closed IBATIS-620.
--------------------------------

    Resolution: Invalid

This is normal behavior for Oracle.  If you specify the resultClass, it will return an int or whatever you specify (assuming the driver allows the "casting".

> "select count(*) from table" return BigDecimal value in Oracle
> --------------------------------------------------------------
>
>                 Key: IBATIS-620
>                 URL: https://issues.apache.org/jira/browse/IBATIS-620
>             Project: iBatis for Java
>          Issue Type: Bug
>    Affects Versions: 3.0 Beta 1
>            Reporter: Yuan Tao
>
> 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(i) : rsmd.getColumnName(i));
>       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();
>         // -------------------------------------------------------------

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@...
For additional commands, e-mail: dev-help@...