2021-01-28 10:47:30 +08:00
2021-01-28 10:40:32 +08:00
2021-01-28 10:47:30 +08:00
2021-01-28 09:34:46 +08:00
2021-01-27 15:47:08 +08:00
2021-01-28 10:47:30 +08:00

mybatis-plus-join

支持连表查询的mybatis-plus

运行环境

  • mysql8
  • jdk8
  • mybatis-plus 3.4.2

使用方法

使用

  • entity继承MyBaseEntity
  • mapper继承MyBaseMapper
  • service继承MyBaseService
  • serviceImpl继承MyBaseServiceImpl

MyLambdaQueryWrapper用法

select(UserEntity::getId) 查询指定的字段,支持可变参数

查询user表中的head_img,name和user_address表中的address,tel image 对应sql
image

selectAll(UserEntity.class) 查询UserEntity全部字段

查询user全部字段和user_address表中的address,tel image 对应sql
image

as(UserEntity::getHeadImg,UserDTO::getUserHeadImg)

查询字段head_img as userHeadImg image 对应sql
image

左连接 leftJoin(UserEntity::getId,UserAddressEntity::getUserId,right -> right)

前连个参数是两个表的连接条件:
user left join user_address on user.id = User_address.user_id
第三个参数是右表wrapper对象,可以继续使用,以上方法.

条件查询eq()

image 对应sql
image

参考测试类

Description
No description provided
Readme Apache-2.0 4.3 MiB
Languages
Java 94.7%
Kotlin 5.3%