mybatis-plus-join
使用方法
安装
-
在项目中添加依赖
<dependency> <groupId>com.github.yulichang</groupId> <artifactId>mybatis-plus-join</artifactId> <version>1.2.2</version> </dependency>
或者clone代码到本地,执行mvn install,再引入以上依赖
注意: mybatis plus version >= 3.4.0
使用
- mapper继承MPJBaseMapper (必选)
- service继承MPJBaseService (可选)
- serviceImpl继承MPJBaseServiceImpl (可选)
核心类 MPJLambdaWrapper和MPJQueryWrapper
MPJLambdaWrapper用法
MPJLambdaWrapper示例
简单的3表查询
class test {
@Resource
private UserMapper userMapper;
void testJoin() {
List<UserDTO> list = userMapper.selectJoinList(UserDTO.class,
new MPJLambdaWrapper<UserDO>()
.selectAll(UserDO.class)
.select(UserAddressDO::getTel)
.selectAs(UserAddressDO::getAddress, UserDTO::getUserAddress)
.select(AreaDO::getProvince, AreaDO::getCity)