exists查询(query exists)
Mapper 内置方法
exists(Where)
:动态条件,exists查询
动态where查询
java
public class Demo {
@Autowired
private SysUserMapper sysUserMapper;
public void exists() {
boolean exists= sysUserMapper.exists(where->{
where.like(SysUser::getUserName,"abc");
});
}
}
基于QueryChain(强大)
可构建复杂的场景, 更多操作前往 链路查询 - QueryChain !
java
public class Demo {
@Autowired
private SysUserMapper sysUserMapper;
public void count() {
boolean exists= QueryChain.of(sysUserMapper)
.like(SysUser::getUserName,"abc")
.exists();
}
}