Closed kco1989 closed 5 years ago
你有复现 demo 吗?
复现的demo在 https://github.com/kco1989/test-mybatis-plus.git 的 mybatis-plus-bug分支上 运行测试类com.kco.SampleTest#pageTest3
加上
@NoArgsConstructor
@AllArgsConstructor
这两个注解,你这是没有空构造函数导致的问题
加上
@NoArgsConstructor @AllArgsConstructor
这两个注解,你这是没有空构造函数导致的问题
这个报错也太迷了吧。。。和Number format 有啥关系
!!! 终于找到了结局方案!!! 谢谢 @miemieYaho
当前使用版本(必须填写清楚,否则不予处理)
mybatis-plus-boot-starter : 3.1.0
该问题是怎么引起的?*([最新版](https://search.maven.org/search?q=g:com.baomidou%20a:mybatis-)上已修复的会直接close掉)**
最近在学习mybatis-plus,发现一个奇怪的问题,使用的mybatis-plus官方例子 表定义: CREATE TABLE user ( id BIGINT(20) NOT NULL COMMENT '主键ID', user_name VARCHAR(30) NULL DEFAULT NULL COMMENT '姓名', age INT(11) NULL DEFAULT NULL COMMENT '年龄', email VARCHAR(50) NULL DEFAULT NULL COMMENT '邮箱', PRIMARY KEY (id) ); 类定义 @Data @Builder @TableName(value = "user") public class UserBean {
} 然后运行分页查询,程序直接报错,参考代码在 https://github.com/kco1989/test-mybatis-plus.git 的 mybatis-plus-bug分支上(仅仅是测试代码而已) 运行测试类com.kco.SampleTest#pageTest3
如果将UserBean 的age和email调换顺序,再重新运行com.kco.SampleTest#pageTest3,则结果可以正确返回,难倒在将sql的字段解析成java实体类时,还跟成员变量定义的位置有关系??
报错信息
org.springframework.dao.DataIntegrityViolationException: Error attempting to get column 'USER_NAME' from result set. Cause: org.h2.jdbc.JdbcSQLDataException: Data conversion error converting "Jone1" [22018-199] ; Data conversion error converting "Jone1" [22018-199]; nested exception is org.h2.jdbc.JdbcSQLDataException: Data conversion error converting "Jone1" [22018-199]
Caused by: org.h2.jdbc.JdbcSQLDataException: Data conversion error converting "Jone1" [22018-199] at org.h2.message.DbException.getJdbcSQLException(DbException.java:455) at org.h2.message.DbException.getJdbcSQLException(DbException.java:427) at org.h2.message.DbException.get(DbException.java:194) at org.h2.value.Value.convertTo(Value.java:829) at org.h2.value.Value.convertTo(Value.java:703) at org.h2.value.Value.getInt(Value.java:589) at org.h2.jdbc.JdbcResultSet.getInt(JdbcResultSet.java:350) at com.zaxxer.hikari.pool.HikariProxyResultSet.getInt(HikariProxyResultSet.java) at org.apache.ibatis.type.IntegerTypeHandler.getNullableResult(IntegerTypeHandler.java:37) at org.apache.ibatis.type.IntegerTypeHandler.getNullableResult(IntegerTypeHandler.java:26) at org.apache.ibatis.type.BaseTypeHandler.getResult(BaseTypeHandler.java:81) at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.createUsingConstructor(DefaultResultSetHandler.java:672) at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.createByConstructorSignature(DefaultResultSetHandler.java:655) at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.createResultObject(DefaultResultSetHandler.java:618) at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.createResultObject(DefaultResultSetHandler.java:591) at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.getRowValue(DefaultResultSetHandler.java:397) at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleRowValuesForSimpleResultMap(DefaultResultSetHandler.java:354) at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleRowValues(DefaultResultSetHandler.java:328) at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleResultSet(DefaultResultSetHandler.java:301) at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleResultSets(DefaultResultSetHandler.java:194) at org.apache.ibatis.executor.statement.PreparedStatementHandler.query(PreparedStatementHandler.java:65) at org.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:79) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:63) at com.sun.proxy.$Proxy72.query(Unknown Source) at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:63) at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:324) at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:156) at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:109) at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:83) at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:148) at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:141) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:433) ... 37 more Caused by: java.lang.NumberFormatException: For input string: "Jone1" at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) at java.lang.Integer.parseInt(Integer.java:580) at java.lang.Integer.parseInt(Integer.java:615) at org.h2.value.Value.convertToInt(Value.java:936) at org.h2.value.Value.convertTo(Value.java:764) ... 73 more