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

getLocalPage相关问题 #771

Closed
1 task
BeyondTheBlade opened this issue Sep 21, 2023 · 6 comments
Closed
1 task

getLocalPage相关问题 #771

BeyondTheBlade opened this issue Sep 21, 2023 · 6 comments

Comments

@BeyondTheBlade
Copy link

  • 我已在 issues 搜索类似问题,并且不存在相同的问题.

异常模板

使用环境

  • PageHelper 版本:
  • 数据库类型和版本: xxx
  • JDBC_URL: xxx

SQL 解析错误

分页参数

PageHelper.startPage(1, 10);
xxMapper.select(model);

原 SQL

select * from xxx where xxx = xxx

期望的结果:

select * from xxx where xxx = xxx limit 10

完整异常信息

异常信息放在这里

其他类型的错误

功能建议

详细说明,尽可能提供(伪)代码示例。

问题排查出来了,在执行SQL的时候,想要执行一次切面进行数据权限的SQL拼接,但是数据权限里本身存在SQL查询会把pageHelper用了,然后就被clear了,getLocalPage就null了。这个有什么办法控制不自动clear吗。。。

@BeyondTheBlade
Copy link
Author

看了下是不是可以开放setLocalPage方法到PageHepler里就能手动避开了

@abel533
Copy link
Collaborator

abel533 commented Sep 22, 2023

如果用异步(另一个线程)去查询数据权限就没问题..

@abel533
Copy link
Collaborator

abel533 commented Sep 22, 2023

你的切面是针对DAO的吗?

@BeyondTheBlade
Copy link
Author

你的切面是针对DAO的吗?

就是那个doTableFilter的方法,针对所有查询SQL,会去进来拼接字段(类似MP租户的用法),我现在处理好了,修改了你的源码,我觉得还是把setLocalPage开到public就好了

@BeyondTheBlade
Copy link
Author

如果用异步(另一个线程)去查询数据权限就没问题..

个人认为不应该为了这个事情,就把数据权限单独开线程处理,是很浪费性能的一个事情。事实上我只需要在数据权限最上方判断getLocalPage是否有分页有的话clear掉,最后添加finally把page通过setLocalPage塞回去就能避开了。所以开放setLocalPage方法到public是能很大程度上解决这个问题,而不是再开一个线程

pagehelper added a commit that referenced this issue Oct 31, 2023
@pagehelper
Copy link
Owner

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

3 participants