Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3.5.6版本mysql的select语句中对for update的语句生成存在问题 #6068

Open
billydong1973 opened this issue Apr 16, 2024 · 4 comments

Comments

@billydong1973
Copy link

mapper.xml中的sql定义
select *
from sys_sms_send_record
where check_status = #{checkStatus}
order by submit_time asc limit #{limit} for
update

3.5.6版本,执行时,实际执行的语句为
select * from sys_sms_send_record where check_status = 0 for update order by submit_time asc limit 10

for update的位置被插入到 order by之前,执行sql出错,3.5.5版本无此问题。

@nieqiurong
Copy link
Contributor

提供插件配置,和mapper层方法.

@billydong1973
Copy link
Author

@bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
// 多租户插件 必须放到第一位
try {
TenantLineInnerInterceptor tenant = SpringUtils.getBean(TenantLineInnerInterceptor.class);
interceptor.addInnerInterceptor(tenant);
log.info("已加载多租户插件");
} catch (BeansException ignore) {
}
// 数据权限处理
interceptor.addInnerInterceptor(dataPermissionInterceptor());
// 分页插件
interceptor.addInnerInterceptor(paginationInnerInterceptor());
// 乐观锁插件
interceptor.addInnerInterceptor(optimisticLockerInnerInterceptor());
// 防全表更新
interceptor.addInnerInterceptor(blockAttackInnerInterceptor());
return interceptor;
}

mapper.java
public interface SysSmsSendRecordMapper extends BaseMapper {

List selectByCheckStatus(int checkStatus, int limit);

List selectBySendStatus(Long sendStatus, int limit);

}

mapper.xml

<select id="selectByCheckStatus" resultType=xxxxxx.domain.SysSmsSendRecord">
select *
from sys_sms_send_record
where check_status = #{checkStatus}
order by submit_time asc limit #{limit} for
update

select * from sys_sms_send_record where send_status = #{sendStatus} order by submit_time asc limit #{limit} for update

@nieqiurong
Copy link
Contributor

@nieqiurong
Copy link
Contributor

已经反馈给JSqlParser

nieqiurong added a commit that referenced this issue May 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants