java8中LambdaQueryWrapper对象使用

idea新建一个spring boot 项目,然后在pom.xml文件中引入mybatis plus 的依赖:

<!--mybatis plus extension,包含了mybatis plus core-->
<dependency>
    <groupId>com.baomidou</groupId>
    <artifactId>mybatis-plus-boot-starter</artifactId>
    <version>${mybatis-plus.version}</version>
</dependency>

1.QueryWrapper的方法

2.demo

使用的关键的代码
QueryWrapper<PbListBlack> sectionQueryWrapper = new QueryWrapper<>();
sectionQueryWrapper.eq("OPTYPE", 1);
sectionQueryWrapper.eq("BLTYPE", 1);
List<PbListBlack> pbListBlacks = iPbListBlackMapper.selectList(sectionQueryWrapper);

上面这段代码的意思就是,首先新建一个QueryWrapper对象,类型为PbListBlack对象,也就是你需要查询的实体数据,

sectionQueryWrapper.eq(“OPTYPE”, 1);

sectionQueryWrapper.eq(“BLTYPE”, 1);

这两句的意思是PbListBlack对象对应的数据库表中的OPTYPE,BLTYPE字段值要为1

经验分享 程序员 微信小程序 职场和发展