baomidou / mybatis-plus

An powerful enhanced toolkit of MyBatis for simplify development
https://baomidou.com
Apache License 2.0
16.45k stars 4.31k forks source link

[错误报告]: DataChangeRecorderInnerInterceptor 在进行新旧数据比对时,updateValue 转 Comparable 时抛出异常。 #6562

Open musicguoke opened 3 weeks ago

musicguoke commented 3 weeks ago

确认

当前程序版本

3.5.7

问题描述

DataChangeRecorderInnerInterceptor 中的 DataColumnChangeResult#isDataChanged 方法内,将 originalValueupdateValue 进行比对判断其是否变化时,当 updateValue 没有实现 Comparable 相关接口导致类型转换失败。 例如: 当 updateValue 类型为 Jackson中的 JsonNode 时。

详细堆栈日志

java.lang.ClassCastException: class com.fasterxml.jackson.databind.node.ObjectNode cannot be cast to class java.lang.Comparable (com.fasterxml.jackson.databind.node.ObjectNode is in unnamed module of loader 'app'; java.lang.Comparable is in module java.base of loader 'bootstrap')
    at com.baomidou.mybatisplus.extension.plugins.inner.DataChangeRecorderInnerInterceptor$DataColumnChangeResult.isDataChanged(DataChangeRecorderInnerInterceptor.java:873) ~[classes/:na]
    at com.baomidou.mybatisplus.extension.plugins.inner.DataChangeRecorderInnerInterceptor$DataChangedRecord.hasUpdate(DataChangeRecorderInnerInterceptor.java:952) ~[classes/:na]
    at com.baomidou.mybatisplus.extension.plugins.inner.DataChangeRecorderInnerInterceptor.compareAndGetUpdatedColumnDatas(DataChangeRecorderInnerInterceptor.java:386) ~[classes/:na]
    at com.baomidou.mybatisplus.extension.plugins.inner.DataChangeRecorderInnerInterceptor.processUpdate(DataChangeRecorderInnerInterceptor.java:249) ~[classes/:na]
    at com.baomidou.mybatisplus.extension.plugins.inner.DataChangeRecorderInnerInterceptor.beforePrepare(DataChangeRecorderInnerInterceptor.java:153) ~[classes/:na]
    at com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor.intercept(MybatisPlusInterceptor.java:102) ~[mybatis-plus-extension-3.5.7.jar:3.5.7]
    at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:59) ~[mybatis-3.5.16.jar:3.5.16]
    at jdk.proxy2/jdk.proxy2.$Proxy124.prepare(Unknown Source) ~[na:na]
    at org.apache.ibatis.executor.SimpleExecutor.prepareStatement(SimpleExecutor.java:90) ~[mybatis-3.5.16.jar:3.5.16]
    at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:49) ~[mybatis-3.5.16.jar:3.5.16]
    at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:117) ~[mybatis-3.5.16.jar:3.5.16]
    at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:76) ~[mybatis-3.5.16.jar:3.5.16]
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[na:na]
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
    at java.base/java.lang.reflect.Method.invoke(Method.java:568) ~[na:na]
    at org.apache.ibatis.plugin.Invocation.proceed(Invocation.java:61) ~[mybatis-3.5.16.jar:3.5.16]
    at com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor.intercept(MybatisPlusInterceptor.java:106) ~[mybatis-plus-extension-3.5.7.jar:3.5.7]
    at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:59) ~[mybatis-3.5.16.jar:3.5.16]
    at jdk.proxy2/jdk.proxy2.$Proxy123.update(Unknown Source) ~[na:na]
    at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:197) ~[mybatis-3.5.16.jar:3.5.16]
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[na:na]
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
    at java.base/java.lang.reflect.Method.invoke(Method.java:568) ~[na:na]
    at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:425) ~[mybatis-spring-3.0.3.jar:3.0.3]
    at jdk.proxy2/jdk.proxy2.$Proxy89.update(Unknown Source) ~[na:na]
    at org.mybatis.spring.SqlSessionTemplate.update(SqlSessionTemplate.java:288) ~[mybatis-spring-3.0.3.jar:3.0.3]
    at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.execute(MybatisMapperMethod.java:64) ~[mybatis-plus-core-3.5.7.jar:3.5.7]
    at com.baomidou.mybatisplus.core.override.MybatisMapperProxy$PlainMethodInvoker.invoke(MybatisMapperProxy.java:152) ~[mybatis-plus-core-3.5.7.jar:3.5.7]
    at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.invoke(MybatisMapperProxy.java:89) ~[mybatis-plus-core-3.5.7.jar:3.5.7]
    at jdk.proxy3/jdk.proxy3.$Proxy112.updateById(Unknown Source) ~[na:na]