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

selectOne方法被加limit分页 #6260

Closed
littlebearrun opened this issue Jun 15, 2024 · 5 comments
Closed

selectOne方法被加limit分页 #6260

littlebearrun opened this issue Jun 15, 2024 · 5 comments

Comments

@littlebearrun
Copy link

baseMapper.selectOne(new QueryWrapper().lambda()
.eq(xxxx)
.eq(xxxx)
.last("LIMIT 1"));
就是简单的controller请求进来查询了这一次
报错后提示语句异常,发现打印出的语句LIMIT 1后面又加了limit 10,偶发了 一次,没再复现,想问一下,什么情况下会出现这种异常?

@ESCATS
Copy link

ESCATS commented Jun 15, 2024

看看日志

@miemieYaho
Copy link
Member

你用了pagehelper吧

@zhaokjun
Copy link

估计是上一次查询的时候用了pagehelper,然后某种原因(比如在查sql前报错、if else中遗漏了一些情况)导致没有办法清空pagehelper的threadlocal,后续调用其他接口时刚好是原来的线程在执行,然后就被加了limit 10

@zhaokjun
Copy link

zhaokjun commented Jun 17, 2024

补充一点:调用了pagehelper.startPage方法后必须对数据库进行一次操作或者手动调用clear方法才能清空threadlocal

@littlebearrun
Copy link
Author

估计是上一次查询的时候用了pagehelper,然后某种原因(比如在查sql前报错、if else中遗漏了一些情况)导致没有办法清空pagehelper的threadlocal,后续调用其他接口时刚好是原来的线程在执行,然后就被加了limit 10

明白你的意思了,有可能是复用了其他带着分页信息的线程

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants