记一次由无参构造引发的血案(Mybatis)
- 问题描述
-
-
- Error querying database. Cause: org.apache.ibatis.executor.result.ResultMapException: Error attempting to get column 'sbxlh' from result set. Cause: java.sql.SQLDataException: Cannot convert string 'KF2020000002' to java.sql.Timestamp value
- The error may exist in org/apache/ibatis/submitted/typehandler/Mapper.java (best guess)
- The error may involve org.apache.ibatis.submitted.typehandler.Mapper.getPictureById
- The error occurred while handling results
- SQL: select * from picture where id = ?
- Cause: org.apache.ibatis.executor.result.ResultMapException: Error attempting to get column 'sbxlh' from result set. Cause: java.sql.SQLDataException: Cannot convert string 'KF2020000002' to java.sql.Timestamp value
- 问题分析
- 问题定位
-
问题描述
在使用Mybatis开发的过程中出现了一个严重的bug,这个异常描述如下:
org.apache.ibatis.exceptions.PersistenceException:
Error querying database. Cause: org.apache.ibatis.executor.result.ResultMapException: Error attempting to get column ‘sbxlh’ from result set. Cause: java.sql.SQLDataException: Cannot convert string ‘KF2020000002’ to java.sql.Timestamp value
The error may exist in org/apache/ibatis/submitted/typehandler/Mapper.java (best guess)
The error may involve org.apache.ibatis.submitted.typehandler.Mapper.getPictureById
The error occurred while handling results
SQL: select * from picture where id = ?
Cause: org.apache.ibatis.executor.result.ResultMapException: Error attempting to get column ‘sbxlh’ from result set. Cause: java.sql.SQLDataException: Cannot convert string ‘KF2020000002’ to java.sql.Timestamp value
at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:155)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:142)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:78)
at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:94)
at org.apache.ibatis.binding.MapperProxy$PlainMethodInvoker.invoke(MapperProxy.java:144)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:85)
at com.sun.proxy.$Proxy20.getPictureById(Unknown Source)
at org.apache.ibatis.submitted.typehandler.TypeHandlerTest.shouldGetPicture(TypeHandlerTest.java:161)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:686)
at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)
at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:131)
at org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:149)
at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:140)
at org.junit.jup