确认

  • [X] 我使用的版本是最新版, 并且使用插件确认过项目里无依赖版本冲突
  • [X] 我已经在 issue 中搜索过, 确认问题没有被提出过
  • [X] 我已经修改标题, 将标题中的 描述 替换为遇到的问题

当前程序版本

3.5.8

问题描述

Executor在代理模式会使以下代码重复执行,导致输出结果出现LIMIT ? LIMIT ?,可能Executor设置为代理模式不是正确的,但我目前找不到其他解决方案 if (!isUpdate && ms.getSqlCommandType() == SqlCommandType.SELECT) { RowBounds rowBounds = (RowBounds) args[2]; ResultHandler resultHandler = (ResultHandler) args[3]; BoundSql boundSql; if (args.length == 4) { boundSql = ms.getBoundSql(parameter); } else { // 几乎不可能走进这里面,除非使用Executor的代理对象调用query[args[6]] boundSql = (BoundSql) args[5]; } for (InnerInterceptor query : interceptors) { if (!query.willDoQuery(executor, ms, parameter, rowBounds, resultHandler, boundSql)) { return Collections.emptyList(); } query.beforeQuery(executor, ms, parameter, rowBounds, resultHandler, boundSql); } CacheKey cacheKey = executor.createCacheKey(ms, parameter, rowBounds, boundSql); return executor.query(ms, parameter, rowBounds, resultHandler, cacheKey, boundSql);

详细堆栈日志

org.springframework.jdbc.BadSqlGrammarException: 
### Error querying database.  Cause: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LIMIT 10' at line 1
### The error may exist in com/chainxi/system/mapper/user/SysUserMapper.java (best guess)
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### SQL: SELECT id, user_name, password, nick_name, dept_id, email, phone_number, sex, avatar, remark, status, login_ip, login_date, create_time, update_time, updater, deleted FROM sys_user WHERE deleted = 0 ORDER BY id DESC LIMIT ? LIMIT ?
### Cause: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LIMIT 10' at line 1
; bad SQL grammar []; nested exception is java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LIMIT 10' at line 1
    at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:236)
    at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:73)
    at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:92)
    at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:439)
    at com.sun.proxy.$Proxy126.selectList(Unknown Source)
    at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:224)
    at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.executeForMany(MybatisMapperMethod.java:164)
    at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.execute(MybatisMapperMethod.java:77)
    at com.baomidou.mybatisplus.core.override.MybatisMapperProxy$PlainMethodInvoker.invoke(MybatisMapperProxy.java:152)
    at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.invoke(MybatisMapperProxy.java:89)
    at com.sun.proxy.$Proxy129.selectList(Unknown Source)
    at com.baomidou.mybatisplus.core.mapper.BaseMapper.selectPage(BaseMapper.java:348)
    at java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:627)
    at com.baomidou.mybatisplus.core.override.MybatisMapperProxy$DefaultMethodInvoker.invoke(MybatisMapperProxy.java:166)
    at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.invoke(MybatisMapperProxy.java:89)
    at com.sun.proxy.$Proxy129.selectPage(Unknown Source)
    at com.chainxi.common.web.core.mapper.BaseMapperX.selectPage(BaseMapperX.java:33)