问题描述
查询数据库结果集设置失败,数据库字段为VARCHAR
,Entity
中映射的也是String
,结果提示无法将XXX
转换成Integer
的异常
关键词
Cannot determine value type from string
Invalid value for getInt()
问题原因
实体类中未设置无参构造函数
sql
select name from t WHERE id=1;
相关异常内容
mysql:mysql-connector-java:5.1.35
org.springframework.dao.TransientDataAccessResourceException: Error attempting to get column 'name' from result set. Cause: java.sql.SQLException: Invalid value for getInt() - '文档8170.xls'
; Invalid value for getInt() - '文档817'; nested exception is java.sql.SQLException: Invalid value for getInt() - '文档817'
at org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.doTranslate(SQLStateSQLExceptionTranslator.java:110)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81)
at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:73)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:446)
at com.sun.proxy.$Proxy95.selectList(Unknown Source)
at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:230)
at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:144)
at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:77)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:58)
at com.sun.proxy.$Proxy100.selectByExample(Unknown Source)
mysql:mysql-connector-java:8.0.15
org.springframework.dao.DataIntegrityViolationException: Error attempting to get column 'name' from result set. Cause: java.sql.SQLDataException: Cannot determine value type from string '文档8170.xls'
; Cannot determine value type from string '文档817'; nested exception is java.sql.SQLDataException: Cannot determine value type from string '文档817'
at org.springframework.jdbc.support.SQLExceptionSubclassTranslator.doTranslate(SQLExceptionSubclassTranslator.java:84)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81)
at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:73)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:446)
at com.sun.proxy.$Proxy95.selectList(Unknown Source)
at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:230)
at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:144)
at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:77)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:58)
at com.sun.proxy.$Proxy100.selectByExample(Unknown Source)