mybatis-plus返回查询总记录数方式
更新时间:2022年01月15日 11:49:29 作者:java1234_小锋
这篇文章主要介绍了mybatis-plus返回查询总记录数方式,具有很好的参考价值,希望对大家有所帮助。如有错误或未考虑完全的地方,望不吝赐教
mybatis-plus返回查询总记录数
mp框架提供了selectCount方法,来查询总记录数;
需求:
查找薪水大于3500 名字里有“小”的 员工的个数
sql实现:
select count(*) from t_employee where salary>3500 and name like ‘%小%'
代码实现:
@Test
public 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);
}mybatis-plus分页查询,总条数为零的解决
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;
}
}以上为个人经验,希望能给大家一个参考,也希望大家多多支持脚本之家。
相关文章
SpringBoot 集成Kaptcha实现验证码功能实例详解
在一个web应用中验证码是一个常见的元素。今天给大家介绍一下kaptcha的和springboot一起使用的简单例子。感兴趣的朋友参考下吧2017-08-08
Springboot初始化启动报错Error creating bean with name 'da
这篇文章主要为大家介绍了Springboot初始化启动报Error creating bean with name 'dataSource' defined in class path resource解决,有需要的朋友可以借鉴参考下,希望能够有所帮助,祝大家多多进步,早日升职加薪2023-08-08
SpringBoot打包后无法读取到resource下的资源文件的解决
这篇文章主要介绍了SpringBoot打包后无法读取到resource下的资源文件的解决方案,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教2025-04-04


最新评论