Skip to content

count查询(query count)

Mapper 内置方法

  • count(Where):动态条件,count查询

动态where查询

java
public class Demo {
    @Autowired
    private SysUserMapper sysUserMapper;
    
    public void count() {
       Integer count= sysUserMapper.count(where->{
           where.like(SysUser::getUserName,"abc");
       });
    }
}

基于QueryChain(强大)

可构建复杂的场景, 更多操作前往 链路查询 - QueryChain

java
public class Demo {
    @Autowired
    private SysUserMapper sysUserMapper;

    public void count() {
        Integer count= QueryChain.of(sysUserMapper)
                .like(SysUser::getUserName,"abc")
                .count();
    }
}