2.2.1 - 2023-12-16
- 复杂example查询示例
- 测试批量插入ID
- 完善测试代码
- JPA不加注解时排除接口、数组、枚举、基本类型、注解类型,fixed #93
- 依赖的 mybatis-provider 升级为 2.2.3
Example 示例
Example<User> example = new Example<>();
example.createCriteria().andEqualTo(User::getSex, "男").andOr(
example.orPart().andLike(User::getUserName, "杨%"),
example.orPart().le(User::getId, 10));
List<User> users1 = mapper.selectByExample(example);
//wrapper写法,结果一样
List<User> list = mapper.wrapper().eq(User::getSex, "男")
.or(
c -> c.startsWith(User::getUserName, "杨"),
c -> c.le(User::getId, 10)).list();
生成的 SQL:
SELECT id,name AS userName,sex,status FROM user WHERE ( sex = ? AND ( ( name LIKE ? ) OR ( id <= ? ) ) )
简化括号后:
SELECT id,name AS userName,sex,status FROM user WHERE sex = ? AND ( name LIKE ? OR id <= ? )