QueryWrapper<PrpLPayAuthorizer> queryWrapper = new QueryWrapper<>(); 包含的用法示例
时间: 2023-11-17 21:55:39 浏览: 74
QueryWrapper 常用用法
QueryWrapper<PrpLPayAuthorizer> 是 Mybatis-Plus 框架中提供的查询构造器,用于构建查询条件。通过 QueryWrapper,我们可以方便地进行单表的增删改查操作。下面是这段代码的使用示例:
1. 查询所有记录:
```
List<PrpLPayAuthorizer> list = queryWrapper.list();
```
2. 根据指定字段查询:
```
queryWrapper.eq("field", value);
```
3. 分页查询:
```
Page<PrpLPayAuthorizer> page = new Page<>(1, 10);
IPage<PrpLPayAuthorizer> iPage = prpLPayAuthorizerMapper.selectPage(page, queryWrapper);
```
4. 自定义 SQL 查询:
```
queryWrapper.apply("1=1");
```
5. 多条件查询:
```
queryWrapper.eq("field1", value1).ne("field2", value2).like("field3", value3);
```
6. 组合条件查询:
```
queryWrapper.and(wrapper -> wrapper.eq("field1", value1).ne("field2", value2)).or(wrapper -> wrapper.like("field3", value3));
```
7. 排序查询:
```
queryWrapper.orderByAsc("field1").orderByDesc("field2");
```
8. 列查询:
```
queryWrapper.select("field1", "field2", "field3");
```
9. 子查询:
```
QueryWrapper<PrpLPolicy> subQueryWrapper = new QueryWrapper<>();
subQueryWrapper.eq("field", value);
queryWrapper.inSql("id", subQueryWrapper.getSqlSegment());
```
阅读全文