mybatis plus or and 的合并写法实例
作者:千百元
这篇文章主要介绍了mybatis plus or and 的合并写法实例,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
我就废话不多说了,大家还是直接看代码吧~
int count =hrDeliverEmployContractService.selectCount(new EntityWrapper<HrDeliverEmployContractEntity>() .eq("pool_id",hrDeliverEmployContract.getPoolId()).andNew().lt("contract_start_date",hrDeliverEmployContract.getContractStartDate()).or().gt("contract_end_date",hrDeliverEmployContract.getContractEndDate()) );
对应的SQL
SELECT COUNT(1) FROM hr_deliver_employ_contract WHERE (pool_id = 1) AND (contract_start_date < '2018-07-01 00:00:00.0' OR contract_end_date > '2018-10-31 00:00:00.0');
补充:mybatis plus or使用
QueryWrapper queryWrapper = new QueryWrapper(); queryWrapper .and(wrapper -> wrapper.isNull(“sim”).or().eq(“sim”, “”)); queryWrapper .eq(“is_delete”, “0”);
对应sql语句
select * from vehicle where (sim is null or sim='') and is_delete=‘0' QueryWrapper queryWrapper = new QueryWrapper(); queryWrapper .eq(“name”,“测试”).or().eq(“sim”,“2”);
对应sql语句
select * from vehicle where name=‘测试' or sim=‘2'
以上为个人经验,希望能给大家一个参考,也希望大家多多支持脚本之家。如有错误或未考虑完全的地方,望不吝赐教。