baomidou / mybatis-plus

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

selectList数组越界,select15个字段,数组越界16,而且无法复现,怀疑读取字段列表时使用了过期的缓存或者错误数据或者并发导致的 #5778

Closed OnlyHelloWorld closed 6 months ago

OnlyHelloWorld commented 12 months ago

当前使用版本(必填,否则不予处理)

3.3.1

该问题是如何引起的?(确定最新版也有问题再提!!!)

List statDefs = statDefMapper.selectList(Wrappers.lambdaQuery(StatDef.class) .eq(StatDef::getSourceDimenRelateId, "0001") .eq(StatDef::getCompileEnable, "1") .orderBy(true, true, StatDef::getIsSolid, StatDef::getRecCrtTs)); 这个方法引起的

重现步骤(如果有就写完整)

未能复现

报错信息

SQL: SELECT 共15个字段 FROM tbl_arfpm_stat_def WHERE (source_dimen_relate_id = ? AND compile_enable = ?) ORDER BY is_solid ASC,rec_crt_ts ASC

Cause: java.sql.SQLException: java.lang.ArrayIndexOutOfBoundsException: 16

; java.lang.ArrayIndexOutOfBoundsException: 16; nested exception is java.sql.SQLException: java.lang.ArrayIndexOutOfBoundsException: 16 at org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.doTranslate(SQLStateSQLExceptionTranslator.java:110) at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72) 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:88) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:440) at com.sun.proxy.$Proxy133.selectList(Unknown Source) at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:223) at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.executeForMany(MybatisMapperMethod.java:177) at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.execute(MybatisMapperMethod.java:78) at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.invoke(MybatisMapperProxy.java:96) at com.sun.proxy.$Proxy149.selectList(Unknown Source) at sun.reflect.GeneratedMethodAccessor177.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:344) at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:198) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at Caused by: java.sql.SQLException: java.lang.ArrayIndexOutOfBoundsException: 16 at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129) at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97) at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:89) at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:63) at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:73) at com.mysql.cj.jdbc.ServerPreparedStatement.executeInternal(ServerPreparedStatement.java:441) at com.mysql.cj.jdbc.ClientPreparedStatement.execute(ClientPreparedStatement.java:370) at sun.reflect.GeneratedMethodAccessor158.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.mysql.cj.jdbc.ha.MultiHostConnectionProxy$JdbcInterfaceProxy.invoke(MultiHostConnectionProxy.java:108) at com.sun.proxy.$Proxy191.execute(Unknown Source) at com.zaxxer.hikari.pool.ProxyPreparedStatement.execute(ProxyPreparedStatement.java:44) at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.execute(HikariProxyPreparedStatement.java) at org.apache.ibatis.executor.statement.PreparedStatementHandler.query(PreparedStatementHandler.java:64) at org.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:79) at com.baomidou.mybatisplus.core.executor.MybatisSimpleExecutor.doQuery(MybatisSimpleExecutor.java:67) at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:324) at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:156) at com.baomidou.mybatisplus.core.executor.MybatisCachingExecutor.query(MybatisCachingExecutor.java:163) at com.baomidou.mybatisplus.core.executor.MybatisCachingExecutor.query(MybatisCachingExecutor.java:90) at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:147) at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:140) at sun.reflect.GeneratedMethodAccessor176.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:426) ... 33 more Caused by: java.lang.ArrayIndexOutOfBoundsException: 16 at com.mysql.cj.protocol.a.NativePacketPayload.readInteger(NativePacketPayload.java:382) at com.mysql.cj.protocol.a.ColumnDefinitionReader.unpackField(ColumnDefinitionReader.java:99) at com.mysql.cj.protocol.a.ColumnDefinitionReader.read(ColumnDefinitionReader.java:77) at com.mysql.cj.protocol.a.ColumnDefinitionReader.read(ColumnDefinitionReader.java:40) at com.mysql.cj.protocol.a.NativeProtocol.read(NativeProtocol.java:1583) at com.mysql.cj.protocol.a.BinaryResultsetReader.read(BinaryResultsetReader.java:70) at com.mysql.cj.protocol.a.BinaryResultsetReader.read(BinaryResultsetReader.java:50) at com.mysql.cj.protocol.a.NativeProtocol.read(NativeProtocol.java:1596) at com.mysql.cj.protocol.a.NativeProtocol.readAllResults(NativeProtocol.java:1650) at com.mysql.cj.ServerPreparedQuery.readExecuteResult(ServerPreparedQuery.java:389) at com.mysql.cj.ServerPreparedQuery.serverExecute(ServerPreparedQuery.java:208) at com.mysql.cj.jdbc.ServerPreparedStatement.serverExecute(ServerPreparedStatement.java:635) at com.mysql.cj.jdbc.ServerPreparedStatement.executeInternal(ServerPreparedStatement.java:418) ... 54 more

OnlyHelloWorld commented 12 months ago

补充:版本和数据库都没更新过,前后两天都能运行,后续补跑也没问题

OnlyHelloWorld commented 12 months ago

还有个情况是这个查询时循环执行的,只是getSourceDimenRelateId参数不同

miemieYaho commented 12 months ago

你实体类有无参构造吗?

OnlyHelloWorld commented 12 months ago

你实体类有无参构造吗?

有默认的无参构造,实体类上面只有Data 和 Table注解