mybatis-plus返回查詢總記錄數(shù)方式
更新時間:2022年01月15日 11:49:29 作者:java1234_小鋒
這篇文章主要介紹了mybatis-plus返回查詢總記錄數(shù)方式,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
mybatis-plus返回查詢總記錄數(shù)
mp框架提供了selectCount方法,來查詢總記錄數(shù);
需求:
查找薪水大于3500 名字里有“小”的 員工的個數(shù)
sql實現(xiàn):
select count(*) from t_employee where salary>3500 and name like ‘%小%'
代碼實現(xiàn):
@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分頁查詢,總條數(shù)為零的解決
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; ? ? } }
以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關(guān)文章
Spring Security整合KeyCloak保護(hù)Rest API實現(xiàn)詳解
這篇文章主要為大家介紹了Spring Security整合KeyCloak保護(hù)Rest API實現(xiàn)實例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-11-11SpringBoot關(guān)于自定義注解實現(xiàn)接口冪等性方式
這篇文章主要介紹了SpringBoot關(guān)于自定義注解實現(xiàn)接口冪等性方式,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2022-11-11SpringBoot?自定義注解實現(xiàn)涉密字段脫敏
關(guān)于數(shù)據(jù)脫敏,網(wǎng)上的文章都是硬編碼規(guī)則,比如對身份證,手機(jī)號,郵件地址等固定寫法脫敏。本文在此基礎(chǔ)上,拓展動態(tài)從數(shù)據(jù)庫查出涉密關(guān)鍵字執(zhí)行脫敏操作。感興趣的同學(xué)可以參考閱讀2023-03-03詳解Spring Boot實現(xiàn)日志記錄 SLF4J
本篇文章主要介紹了詳解Spring Boot實現(xiàn)日志記錄 SLF4J,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2017-05-05springboot實現(xiàn)郵箱發(fā)送(激活碼)功能的示例代碼
這篇文章主要為大家詳細(xì)介紹了如何利用springboot實現(xiàn)郵箱發(fā)送(激活碼)功能,文中的示例代碼簡潔易懂,有需要的小伙伴可以跟隨小編一起學(xué)習(xí)一下2023-10-10