MyBatisPlus条件构造器带条件查询selectList使用

场景

项目搭建专栏:

https://blog.csdn.net/BADAO_LIUMANG_QIZHI/column/info/37194

基础搭建:

https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/89407994

条件构造器介绍使用:

https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/89482201

实现

新建测试方法

/***
  *条件构造器 查询操作SelectList
  */
 @Test
 public void testEntitymapperSelectList() {
  //查询数据库,性别为男(1),并且名字中带有霸的记录或者email中带有123的记录。
  List employeeList=employeeMapper.selectList(new EntityWrapper()
    .eq("gender",1)
    .like("name", "霸")
    //.or()//SELECT id AS id,`name`,email,gender,age FROM employee WHERE (gender = ? AND name LIKE ? OR email LIKE ?)
    .orNew()//SELECT id AS id,`name`,email,gender,age FROM employee WHERE (gender = ? AND name LIKE ?) OR (email LIKE ?)
    .like("email", "123")
    );
  System.out.println("*******************"+employeeList);
  for (Employee employee : employeeList) {
   System.out.println(employee.getName());
  }
 }

运行测试方法:

MyBatisPlus条件构造器带条件查询selectList使用_第1张图片

MyBatisPlus条件构造器带条件查询selectList使用_第2张图片

源码下载

https://download.csdn.net/download/badao_liumang_qizhi/11136765

你可能感兴趣的:(selectList,MyBatisPlus)