batchSave IndexOutOfBoundsException
Bug Report
version: 4.0.0-RC1-RELEASE 4.0.0.RC1-SNAPSHOT
myBatisPlus 3.1.0
batchInsert will throwable IndexOutOfBoundsException: Index:0, Size 0
err msg:
at java.util.LinkedList.checkElementIndex(LinkedList.java:555)
at java.util.LinkedList.get(LinkedList.java:476)
at org.apache.shardingsphere.core.optimize.result.InsertColumnValues$InsertColumnValue.getColumnSQLExpressionValue(InsertColumnValues.java:154)
at org.apache.shardingsphere.core.optimize.result.InsertColumnValues$InsertColumnValue.fillResultByValues(InsertColumnValues.java:148)
at org.apache.shardingsphere.core.optimize.result.InsertColumnValues$InsertColumnValue.toString(InsertColumnValues.java:133)
at java.lang.String.valueOf(String.java:2981)
at java.lang.StringBuilder.append(StringBuilder.java:131)
at org.apache.shardingsphere.core.rewrite.SQLBuilder.appendInsertColumnValue(SQLBuilder.java:197)
at org.apache.shardingsphere.core.rewrite.SQLBuilder.appendInsertValuesPlaceholder(SQLBuilder.java:190)
at org.apache.shardingsphere.core.rewrite.SQLBuilder.toSQL(SQLBuilder.java:115)
at org.apache.shardingsphere.core.rewrite.SQLRewriteEngine.generateSQL(SQLRewriteEngine.java:507)
at org.apache.shardingsphere.core.BaseShardingEngine.rewriteAndConvert(BaseShardingEngine.java:90)
at org.apache.shardingsphere.core.BaseShardingEngine.shard(BaseShardingEngine.java:65)
at org.apache.shardingsphere.shardingjdbc.jdbc.core.statement.ShardingPreparedStatement.shard(ShardingPreparedStatement.java:224)
at org.apache.shardingsphere.shardingjdbc.jdbc.core.statement.ShardingPreparedStatement.addBatch(ShardingPreparedStatement.java:215)
at sun.reflect.GeneratedMethodAccessor486.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:45005)
at java.lang.reflect.Method.invoke(Method.java:483)
before insert the data, I have checked the ArrayList is empty or is null
if (CollectionUtil.isNotEmpty(saveList)){
flag = functionRelationService.saveBatch(saveList);
}
@zcqshine Can you provide your configuration of shardingsphere and your executed SQLs
Hi @zcqshine, I can't reproduce your problem with sharding-jdbc-spring-boot-starter 4.0.0-RC1-SNAPSHOT and mybatis-spring-boot-starter 1.3.2.
Would you mind provide a example code in your GitHub which can reproduce this problem?
sharding configuration:
sharding.jdbc.config.props.sql.show = true
#t_form_template_data 分表设置
sharding.jdbc.config.sharding.tables.t_form_template_data.actual-data-nodes = ds.t_form_template_data_$->{0..40}
sharding.jdbc.config.sharding.tables.t_form_template_data.table-strategy.inline.sharding-column = project_id
sharding.jdbc.config.sharding.tables.t_form_template_data.table-strategy.inline.algorithm-expression = t_form_template_data_$->{project_id % 41}
#t_form_template_struct 分表设置
sharding.jdbc.config.sharding.tables.t_form_template_struct.actual-data-nodes = ds.t_form_template_struct_$->{0..40}
sharding.jdbc.config.sharding.tables.t_form_template_struct.table-strategy.inline.sharding-column = project_id
sharding.jdbc.config.sharding.tables.t_form_template_struct.table-strategy.inline.algorithm-expression = t_form_template_struct_$->{project_id % 41}
mybatis-plus configuration:
mybatis-plus.global-config.db-config.db-type = postgre_sql
mybatis-plus.mapper-locations = classpath:/mapper/*Mapper.xml
mybatis-plus.type-aliases-package = 此处省略扫描的包名
mybatis-plus.global-config.db-config.id-type = id_worker
mybatis-plus.global-config.db-config.field-strategy = not_empty
mybatis-plus.global-config.refresh = true
mybatis-plus.configuration.cache-enabled = false
mybatis-plus.configuration.log-impl = org.apache.ibatis.logging.stdout.StdOutImpl
execute sql is:
INSERT INTO t_form_function_relation ( id, function_id, struct_id, template_id, update_user, create_user, create_time, update_time, del_flag, version ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )
the table t_form_function_relation is not sharding.
if i use sharding-sphere 3.1.0 , the will be ok.
Database is postgresql 10
Hi @zcqshine, what's your database type, if oracle or postgre, the problem has fixed, please pull newest code and retry.
databse is postgre version is 10.x
Let me try
Hi @zcqshine, any new progress?
Hi @zcqshine, any new progress?
sorry, i have no time to retry in these day. I will be tell you after get a result
Hi @zcqshine, any new progress?
sorry, i have no time to retry in these day. I will be tell you after get a result
No problem, but it is best to reply within 7 days, otherwise the issue may be closed.
Hi @zcqshine, any new progress?
sorry, i have no time to retry in these day. I will be tell you after get a result
No problem, but it is best to reply within 7 days, otherwise the issue may be closed.
4.0.0-rc2 is ok