You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
神通数据库使用mp saveBatch会报错,配置@TableId(value = "id", type = IdType.ASSIGN_ID) 可以解决,但是需要根据数据库设置不同的值,Debug发现进入Jdbc3KeyGenerator.processBatch方法中stmt.getGeneratedKeys()返回结果为null,跟到OscarStatement的getGeneratedKeys()方法中this.result为null,后面就不知道怎么看了,不知道为什么单表插入没有问题,批量插入有问题。
详细堆栈日志
org.springframework.jdbc.UncategorizedSQLException: Error getting generated key or setting result to parameter object. Cause: java.sql.SQLException: Error
; uncategorized SQLException; SQL state [null]; error code [0]; Error; nested exception is java.sql.SQLException: Error
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:89)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81)
at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:91)
at com.baomidou.mybatisplus.extension.toolkit.SqlHelper.executeBatch(SqlHelper.java:192)
at com.baomidou.mybatisplus.extension.toolkit.SqlHelper.executeBatch(SqlHelper.java:217)
at com.baomidou.mybatisplus.extension.service.impl.ServiceImpl.executeBatch(ServiceImpl.java:240)
at com.baomidou.mybatisplus.extension.service.impl.ServiceImpl.saveBatch(ServiceImpl.java:136)
at com.baomidou.mybatisplus.extension.service.IService.saveBatch(IService.java:73)
at com.baomidou.mybatisplus.extension.service.IService$$FastClassBySpringCGLIB$$f8525d18.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:769)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:747)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:366)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:99)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:747)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:689)
......
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1639)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.sql.SQLException: Error
at com.alibaba.druid.pool.DruidDataSource.handleConnectionException(DruidDataSource.java:1936)
at com.alibaba.druid.pool.DruidPooledConnection.handleException(DruidPooledConnection.java:124)
at com.alibaba.druid.pool.DruidPooledStatement.checkException(DruidPooledStatement.java:87)
at com.alibaba.druid.pool.DruidPooledResultSet.checkException(DruidPooledResultSet.java:42)
at com.alibaba.druid.pool.DruidPooledResultSet.getMetaData(DruidPooledResultSet.java:419)
at org.apache.ibatis.executor.keygen.Jdbc3KeyGenerator.processBatch(Jdbc3KeyGenerator.java:80)
at org.apache.ibatis.executor.BatchExecutor.doFlushStatements(BatchExecutor.java:129)
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:64)
at com.sun.proxy.$Proxy230.flushStatements(Unknown Source)
at org.apache.ibatis.session.defaults.DefaultSqlSession.flushStatements(DefaultSqlSession.java:249)
at com.baomidou.mybatisplus.extension.toolkit.SqlHelper.lambda$executeBatch$1(SqlHelper.java:224)
at com.baomidou.mybatisplus.extension.toolkit.SqlHelper.executeBatch(SqlHelper.java:182)
... 122 common frames omitted
Suppressed: java.sql.SQLException: Error
at com.alibaba.druid.pool.DruidDataSource.handleConnectionException(DruidDataSource.java:1936)
at com.alibaba.druid.pool.DruidPooledConnection.handleException(DruidPooledConnection.java:124)
at com.alibaba.druid.pool.DruidPooledStatement.checkException(DruidPooledStatement.java:87)
at com.alibaba.druid.pool.DruidPooledResultSet.checkException(DruidPooledResultSet.java:42)
at com.alibaba.druid.pool.DruidPooledResultSet.close(DruidPooledResultSet.java:78)
at org.apache.ibatis.executor.keygen.Jdbc3KeyGenerator.processBatch(Jdbc3KeyGenerator.java:87)
... 135 common frames omitted
Caused by: java.lang.NullPointerException: null
at com.alibaba.druid.pool.DruidPooledResultSet.close(DruidPooledResultSet.java:74)
... 136 common frames omitted
Caused by: java.lang.NullPointerException: null
at com.alibaba.druid.pool.DruidPooledResultSet.getMetaData(DruidPooledResultSet.java:417)
... 136 common frames omitted
跟踪相关代码
OscarStatement.class
public ResultSet getGeneratedKeys() throws SQLException {
if (this.autoGeneratedInfo == -1) {
throw new OSQLException("OSCAR-00420", "88888", 420);
} else if (this.result == null) {
return null;
} else if (!this.result.getStatusString().startsWith("21")) {
return this.createResultSet(new Field[0], new ArrayList(), (String)null, 0, 0L);
} else {
String status = this.result.getStatusString();
int updateCount = this.result.getResultCount();
int insertOID = this.result.getInsertRowid();
Field[] fields = new Field[1];
List tuples = new ArrayList();
fields[0] = new Field(this.connection, "GENERATED_KEY", 26, 4, 0, "GENERATED_KEY", "", "", (byte)0);
byte[] rowIdByte = new byte[]{0};
try {
rowIdByte = String.valueOf(insertOID).getBytes(this.encoding.getEncoding());
} catch (UnsupportedEncodingException var8) {
}
byte[][] tempTuple = new byte[][]{rowIdByte};
tuples.add(tempTuple);
return this.createResultSet(fields, tuples, status, updateCount, (long)insertOID);
}
}
确认
当前程序版本
3.5.1
问题描述
神通数据库使用mp saveBatch会报错,配置@TableId(value = "id", type = IdType.ASSIGN_ID) 可以解决,但是需要根据数据库设置不同的值,Debug发现进入Jdbc3KeyGenerator.processBatch方法中stmt.getGeneratedKeys()返回结果为null,跟到OscarStatement的getGeneratedKeys()方法中this.result为null,后面就不知道怎么看了,不知道为什么单表插入没有问题,批量插入有问题。
详细堆栈日志
跟踪相关代码
OscarStatement.class
Jdbc3KeyGenerator.class
The text was updated successfully, but these errors were encountered: