Open ghost opened 6 years ago
Customer customer = new Customer(); customer.setName("Jack"); customer.setAddress("上海"); //创建匹配器,即如何使用查询条件 ExampleMatcher matcher = ExampleMatcher.matching() //构建对象 .withMatcher("name", GenericPropertyMatchers.startsWith()) //姓名采用“开始匹配”的方式查询 .withIgnorePaths("focus"); //忽略属性:是否关注。因为是基本类型,需要忽略掉 //创建实例 Example<Customer> ex = Example.of(customer, matcher); //查询 List<Customer> ls = dao.findAll(ex); //输出结果 for (Customer bo:ls) { System.out.println(bo.getName()); }