为提高效率,提问时请提供以下信息,问题描述清晰可优先响应。
【DM版本】:
【操作系统】:centos
【CPU】: core i5 11th
【问题描述】*:Mybatis-Plus的saveOrUpdateBatch方法报错
id是自增列,类型为bigInterge
错误信息如下
{conn-10001, pstmt-20012} execute error. insert into ca0301 (ca03id, ca030101, ca030102, ca030103, ca030104)
values (1, '2020-12', 12.1, 1, '备注')
java.lang.RuntimeException: index out of range
at dm.jdbc.util.Buffer.readBytes(Buffer.java:679)
at dm.jdbc.util.Buffer.readBytes(Buffer.java:663)
at dm.jdbc.util.Buffer.readLong(Buffer.java:628)
at dm.jdbc.c.a.d.y(EXECUTE.java:427)
at dm.jdbc.c.a.d.x(EXECUTE.java:1)
at dm.jdbc.c.a.n.F(MSG.java:168)
at dm.jdbc.c.a.a(DBAccess.java:759)
at dm.jdbc.c.a.a(DBAccess.java:311)
at dm.jdbc.c.a.b(DBAccess.java:455)
at dm.jdbc.driver.DmdbPreparedStatement.do_executeLargeBatch(DmdbPreparedStatement.java:404)
at dm.jdbc.driver.DmdbPreparedStatement.do_executeBatch(DmdbPreparedStatement.java:356)
at dm.jdbc.driver.DmdbPreparedStatement.executeBatch(DmdbPreparedStatement.java:1312)
at com.alibaba.druid.filter.FilterChainImpl.statement_executeBatch(FilterChainImpl.java:3118)
at com.alibaba.druid.wall.WallFilter.statement_executeBatch(WallFilter.java:543)
at com.alibaba.druid.filter.FilterChainImpl.statement_executeBatch(FilterChainImpl.java:3116)
at com.alibaba.druid.filter.FilterAdapter.statement_executeBatch(FilterAdapter.java:2507)
at com.alibaba.druid.filter.FilterEventAdapter.statement_executeBatch(FilterEventAdapter.java:279)
at com.alibaba.druid.filter.FilterChainImpl.statement_executeBatch(FilterChainImpl.java:3116)
at com.alibaba.druid.proxy.jdbc.StatementProxyImpl.executeBatch(StatementProxyImpl.java:202)
at com.alibaba.druid.pool.DruidPooledPreparedStatement.executeBatch(DruidPooledPreparedStatement.java:565)
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.logging.jdbc.PreparedStatementLogger.invoke(PreparedStatementLogger.java:78)
at com.sun.proxy.$Proxy235.executeBatch(Unknown Source)
at com.baomidou.mybatisplus.core.executor.MybatisBatchExecutor.doFlushStatements(MybatisBatchExecutor.java:132)
at org.apache.ibatis.executor.BaseExecutor.flushStatements(BaseExecutor.java:129)
at org.apache.ibatis.executor.BaseExecutor.flushStatements(BaseExecutor.java:122)
at org.apache.ibatis.executor.CachingExecutor.flushStatements(CachingExecutor.java:114)
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.$Proxy277.flushStatements(Unknown Source)
at org.apache.ibatis.session.defaults.DefaultSqlSession.flushStatements(DefaultSqlSession.java:252)
at com.baomidou.mybatisplus.extension.service.impl.ServiceImpl.saveOrUpdateBatch(ServiceImpl.java:179)
at com.baomidou.mybatisplus.extension.service.impl.ServiceImpl$$FastClassBySpringCGLIB$$76535273.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:749)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:294)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:98)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:688)
at com.insigma.shanxi.service.impl.Ca0301ServiceImpl$$EnhancerBySpringCGLIB$$1f413cb8.saveOrUpdateBatch(<generated>)
我使用mybatis-plus+druid+dm8 也报了这个错,目前怀疑是druid的wall不支持达梦数据库(wall.config.multiStatementAllow 默认是false,druid默认不支持批处理),使用saveOrUpdateBatch方法的报错堆栈有wall。
参考做配置:https://eco.dameng.com/docs/zh-cn/app-dev/java-MyBatis-Plus-frame.html