We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
我们有一个自己的sql 打印拦截器,当没有开启asyncCount 时,能正常的打印select count() 和select * 两个语句,但是当我打开asyncCount 时,就只打印了select * ,没有打印select count(*)
@Bean @ConditionalOnMissingBean public PageInterceptor pageInterceptor() { Properties properties = new Properties(); properties.setProperty("asyncCount", "true"); PageInterceptor pageInterceptor = new PageInterceptor(); pageInterceptor.setProperties(properties); return pageInterceptor; }
@RequiredArgsConstructor @Intercepts(value = { @Signature(type = Executor.class, method = "update", args = {MappedStatement.class, Object.class}), @Signature(type = Executor.class, method = "query", args = {MappedStatement.class, Object.class, RowBounds.class, ResultHandler.class, CacheKey.class, BoundSql.class}), @Signature(type = Executor.class, method = "query", args = {MappedStatement.class, Object.class, RowBounds.class, ResultHandler.class})}) public class MybatisPrintSqlInterceptor implements Interceptor { private MybatisProperties mybatisProperties; public MybatisPrintSqlInterceptor(MybatisProperties mybatisProperties) { this.mybatisProperties = mybatisProperties; } @Override public Object intercept(Invocation invocation) throws Throwable { Object[] args = invocation.getArgs(); MappedStatement ms = (MappedStatement) args[0]; boolean contains = mybatisProperties.getPrintSqlCommandTypes().contains(ms.getSqlCommandType()); if (contains) { BoundSql boundSql; if (args.length == 2 || args.length == 4) { boundSql = ms.getBoundSql(args[1]); } else { boundSql = (BoundSql) args[5]; } //1.打印将要执行的sql String name = Thread.currentThread().getName(); String sql = getSqlWithValues(boundSql.getSql(), buildParameterValues(ms.getConfiguration(), boundSql)); //......................
Page<UserRole> objectPage = PageHelper.startPage(1, 3); LambdaQueryWrapper<UserRole> lambdaQueryWrapper = new LambdaQueryWrapper<>(); lambdaQueryWrapper.like(UserRole::getUserId, "test"); List<UserRole> list = userRoleService.list(lambdaQueryWrapper); Assertions.assertEquals(list.size(), 3); System.out.println(objectPage); Assertions.assertEquals(objectPage.getTotal(), COUNT);
打印select count() 语句
1.[main]执行的SQL: SELECT roleId,userId FROM UserRole WHERE (userId LIKE '%test%') LIMIT 3 2.[main]执行的Statement: com.guanwei.mybatis.mapper.UserRoleMapper.selectList 3.[main]执行用时: 29 毫秒 Page{count=true, pageNum=1, pageSize=3, startRow=0, endRow=3, total=20, pages=7, reasonable=false, pageSizeZero=true}[UserRole(roleId=111, userId=test111), UserRole(roleId=1110, userId=test1110), UserRole(roleId=1221, userId=test1221)]
实际看出来,total 有值,但是没有打印查询数量的sql,这需要怎么配置
The text was updated successfully, but these errors were encountered:
是这里说明的吧
Sorry, something went wrong.
是这里说明的原因,可以尝试能否避免递归并且支持其他拦截器。
No branches or pull requests
异常模板
使用环境
问题描述
我们有一个自己的sql 打印拦截器,当没有开启asyncCount 时,能正常的打印select count() 和select * 两个语句,但是当我打开asyncCount 时,就只打印了select * ,没有打印select count(*)
JavaPeizhi
期望的结果:
打印select count() 语句
实际结果:
1.[main]执行的SQL: SELECT roleId,userId FROM UserRole WHERE (userId LIKE '%test%') LIMIT 3
2.[main]执行的Statement: com.guanwei.mybatis.mapper.UserRoleMapper.selectList
3.[main]执行用时: 29 毫秒
Page{count=true, pageNum=1, pageSize=3, startRow=0, endRow=3, total=20, pages=7, reasonable=false, pageSizeZero=true}[UserRole(roleId=111, userId=test111), UserRole(roleId=1110, userId=test1110), UserRole(roleId=1221, userId=test1221)]
实际看出来,total 有值,但是没有打印查询数量的sql,这需要怎么配置
The text was updated successfully, but these errors were encountered: