Uploaded image for project: 'Spring Data JDBC'
  1. Spring Data JDBC
  2. DATAJDBC-15

Incorrect output of big numbers when using NamedParameterJdbcTemplate.queryForLong

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Duplicate
    • Affects Version/s: Ext 1.0 M2, Ext 1.0 RC1, Ext 1.0 RELEASE
    • Fix Version/s: None
    • Component/s: ORCL
    • Labels:
      None
    • Environment:
      detected against Oracle 11g DB

      Description

      In a table column we use 19-digit IDs. The column type is set to NUMBER. An example of an ID is "1000000009704976470". Now, if we access by using NamedParameterJdbcTemplate.queryForLong (String sql, SqlParameterSource paramSource) or overloaded methods, it returns the for example the long 1000000009704976512L instead of "1000000009704976470". The cause lies in the implementation of the method queryForLong.

      The current implementation looks like this:
      public long queryForLong(String sql, SqlParameterSource paramSource) throws DataAccessException {
      Number number = queryForObject(sql, paramSource, Number.class);
      return (number != null ? number.longValue() : 0);
      }

      A solution could look like this:
      public long queryForLong(String sql, SqlParameterSource paramSource) throws DataAccessException {
      Number number = queryForObject(sql, paramSource, Long.class);
      return (number != null ? number.longValue() : 0);
      }

      One more note, the JdbcTemplate class implements the method queryForLong properly.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                thomas.risberg Thomas Risberg
                Reporter:
                andre.rouel André Rouél
                Last updater:
                Thomas Risberg
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: