-2

mybatis query bigInteger error here is the stack information,no problem if you shorten the length,e.g 982544369348876697

Cause: java.sql.SQLException: java.lang.NumberFormatException: 9825443693488766976

    ; uncategorized SQLException for SQL []; SQL state [HY000]; error code [1105]; java.lang.NumberFormatException: 9825443693488766976; nested exception is java.sql.SQLException: java.lang.NumberFormatException: 9825443693488766976
    at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:84) ~[spring-jdbc-4.2.6.RELEASE.jar:4.2.6.RELEASE]
    at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81) ~[spring-jdbc-4.2.6.RELEASE.jar:4.2.6.RELEASE]
    at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81) ~[spring-jdbc-4.2.6.RELEASE.jar:4.2.6.RELEASE]
    at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:73) ~[mybatis-spring-1.3.2.jar:1.3.2]
    at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:446) ~[mybatis-spring-1.3.2.jar:1.3.2]
    at com.sun.proxy.$Proxy35.selectList(Unknown Source) ~[?:?]
    at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:230) ~[mybatis-spring-1.3.2.jar:1.3.2]
    at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:128) ~[mybatis-3.4.0.jar:3.4.0]
    at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:68) ~[mybatis-3.4.0.jar:3.4.0]
    at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:53) ~[mybatis-3.4.0.jar:3.4.0]
    at com.sun.proxy.$Proxy69.selectJobTransactionEvent(Unknown Source) ~[?:?]
dev007
  • 1
  • 4
  • 1
    when you down vote question please write the comment about it. So that they won't do it again. Without the comments making down vote makes no sense – Sivabalan May 25 '18 at 10:01
  • Clearly the problem is the number is out of range – user9993 May 25 '18 at 10:07
  • yes,this number is like this,is there a way to solve it?@user9993 – dev007 May 25 '18 at 10:12
  • Please include information about the field type you use, column type and type handler (if any) you use. It is not clear what you mean by `bigInteger` as mybatis does not support `java.math.BigInteger` out of the box. From what you've written it seems that you use long column but the value does not fit. If you use `BigDecimal` column default type handler for it should work. – Roman-Stop RU aggression in UA May 25 '18 at 23:00
  • thanks, this problem has been solved. mybatis support biginteger@RomanKonoval – dev007 May 28 '18 at 05:40

1 Answers1

0

The problem is that you are trying to retrieve a big number from the database, and it cannot be stored in a Java Long (that you specified in your VO).

You don't say what's the column data type but my guess is that it's something like a UNSIGNED BIGINT. These columns support numbers bigger than 9223372036854775807, that is the maximum for a Java Long.

Solution? Use a java.math.BigInteger instead of Long in the Java Value Object. I've tried it and works like charm.

The Impaler
  • 45,731
  • 9
  • 39
  • 76