异常详情
org.springframework.jdbc.UncategorizedSQLException: Error attempting to get column 'update_time' from result set. Cause: java.sql.SQLException: Error
; uncategorized SQLException; SQL state [null]; error code [0]; Error; nested exception is java.sql.SQLException: Error
at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:92)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:441)
at com.sun.proxy.$Proxy158.selectList(Unknown Source)
at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:224)
at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.executeForIPage(MybatisMapperMethod.java:121)
at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.execute(MybatisMapperMethod.java:85)
at com.baomidou.mybatisplus.core.override.MybatisMapperProxy$PlainMethodInvoker.invoke(MybatisMapperProxy.java:148)
at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.invoke(MybatisMapperProxy.java:89)
at com.sun.proxy.$Proxy355.selectPage(Unknown Source)
at com.hongmeng.service.auto_rule.impl.AutomaticRuleTemplateServiceImpl.findByPage(AutomaticRuleTemplateServiceImpl.java:192)
解决方案
重写时间日期类型的处理器,当值为null时直接返回,不执行处理方法
@Component
public class MybatisPlusLocalDateTimeTypeHandler extends LocalDateTimeTypeHandler {
@Override
public LocalDateTime getResult(ResultSet rs, String columnName) throws SQLException {
Object object = rs.getObject(columnName);
if (object == null) {
return null;
}
return super.getResult(rs, columnName);
}
}
@Component
public class MybatisPlusLocalDateTypeHandler extends LocalDateTypeHandler {
@Override
public LocalDate getResult(ResultSet rs, String columnName) throws SQLException {
Object object = rs.getObject(columnName);
if (object == null) {
return null;
}
return super.getResult(rs, columnName);
}
}
@Component
public class MybatisPlusLocalTimeTypeHandler extends LocalTimeTypeHandler {
@Override
public LocalTime getResult(ResultSet rs, String columnName) throws SQLException {
Object object = rs.getObject(columnName);
if (object == null) {
return null;
}
return super.getResult(rs, columnName);
}
}