mybatis-plus lambda条件构造器
mybatis-plus lambda条件构造器
mp框架提供了lambda表达式条件构造器支持;
实例:
/** * 查找薪水大于3500 名字里有“小”的 员工(通过Lambda表达式) * sql: select * from t_employee where salary>3500 and name like '%小%' */ @Test public void selectByQueryWrapperWidthLambda(){ LambdaQueryWrapper<Employee> lambdaQueryWrapper=new QueryWrapper<Employee>().lambda(); // LambdaQueryWrapper<Employee> lambdaQueryWrapper2=new LambdaQueryWrapper(); // LambdaQueryWrapper<Employee> lambdaQueryWrapper3=Wrappers.lambdaQuery(); // queryWrapper.gt("salary",3500).like("name","小"); lambdaQueryWrapper .gt(Employee::getSalary,"3500") .like(Employee::getName,"小"); List<Employee> employeeList = employeeMapper.selectList(lambdaQueryWrapper); System.out.println(employeeList); }
/** * 查找薪水大于3500 名字里有“小”的 员工(通过Lambda表达式) chain * sql: select * from t_employee where salary>3500 and name like '%小%' */ @Test public void selectByQueryWrapperWidthLambda2(){ List<Employee> employeeList = new LambdaQueryChainWrapper<Employee>(employeeMapper) .gt(Employee::getSalary, "3500") .like(Employee::getName, "小") .list(); System.out.println(employeeList); }
------------------------------------------------------------------------------------------------------------------------------
作者: java1234_小锋
出处:https://www.cnblogs.com/java688/p/13672075.html
版权:本站使用「CC BY 4.0」创作共享协议,转载请在文章明显位置注明作者及出处。
------------------------------------------------------------------------------------------------------------------------------
关注微信公众号福利!!!
回复关键字「666」获取66套Java实战项目视频教程,你要的都有!
回复关键字「全栈」获取Java从入门到大神系列全栈开发教程;
回复关键字「面试」获取一份2020Java笔试面试题;
回复关键字「简历」获取50套Java经典优秀简历模版;
回复关键字「BAT」获取历年来BAT笔试面试题打包合集;
回复关键字「666」获取66套Java实战项目视频教程,你要的都有!
回复关键字「全栈」获取Java从入门到大神系列全栈开发教程;
回复关键字「面试」获取一份2020Java笔试面试题;
回复关键字「简历」获取50套Java经典优秀简历模版;
回复关键字「BAT」获取历年来BAT笔试面试题打包合集;