这篇“mybatis-plus返回查询总记录数的方法是什么”文章的知识点大部分人都不太理解,所以小编给大家总结了以下内容,内容详细,步骤清晰,具有一定的借鉴价值,希望大家阅读完这篇文章能有所收获,下面我们一起来看看这篇“mybatis-pl
这篇“mybatis-plus返回查询总记录数的方法是什么”文章的知识点大部分人都不太理解,所以小编给大家总结了以下内容,内容详细,步骤清晰,具有一定的借鉴价值,希望大家阅读完这篇文章能有所收获,下面我们一起来看看这篇“mybatis-plus返回查询总记录数的方法是什么”文章吧。
mp框架提供了selectCount方法,来查询总记录数;
需求:
查找薪水大于3500 名字里有“小”的 员工的个数
sql实现:
select count(*) from t_employee where salary>3500 and name like ‘%小%'
代码实现:
@Testpublic void selectCountByQueryWrapper11(){ QueryWrapper<Employee> queryWrapper=new QueryWrapper(); // QueryWrapper<Employee> queryWrapper2=Wrappers.<Employee>query(); queryWrapper.gt("salary",3500).like("name","小"); Integer count = employeeMapper.selectCount(queryWrapper); System.out.println(count);}
package com.integration.config;import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;import org.mybatis.spring.annotation.MapperScan;import org.springframework.context.annotation.Bean;import org.springframework.context.annotation.Configuration;@Configuration@MapperScan("com.integration.mapper")public class MybatisPlusConfig { @Bean public PaginationInterceptor paginationInterceptor() { PaginationInterceptor page = new PaginationInterceptor(); return page; }}
以上就是关于“mybatis-plus返回查询总记录数的方法是什么”这篇文章的内容,相信大家都有了一定的了解,希望小编分享的内容对大家有帮助,若想了解更多相关的知识内容,请关注编程网精选频道。
--结束END--
本文标题: mybatis-plus返回查询总记录数的方法是什么
本文链接: https://www.lsjlt.com/news/307156.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-04-30
2024-04-30
2024-04-29
2024-04-29
2024-04-29
2024-04-29
2024-04-29
2024-04-29
2024-04-29
2024-04-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0