diff --git a/MAPPING.md b/MAPPING.md
index 01adc3d..7517f9c 100644
--- a/MAPPING.md
+++ b/MAPPING.md
@@ -1,6 +1,6 @@
# mybatis-plus-join
-* 本页功能只能在1.2.0测试版中使用,最新版本 1.2.0.Beta3
+* 本页功能只能在1.2.0测试版中使用,最新版本 1.2.0.Beta5
* 点个Star支持一下吧 :)
@@ -15,12 +15,12 @@ QQ群:1022221898
com.github.yulichang
mybatis-plus-join
- 1.2.0.Beta3
+ 1.2.0.Beta5
```
- Gradle
```
- implementation group: 'com.github.yulichang', name: 'mybatis-plus-join', version: '1.2.0.Beta3'
+ implementation group: 'com.github.yulichang', name: 'mybatis-plus-join', version: '1.2.0.Beta5'
```
或者clone代码到本地执行 mvn install, 再引入以上依赖
@@ -49,18 +49,32 @@ public class UserDO {
/* 其他属性略 */
/**
- * 一对一
+ * 查询上级 一对一
*/
@TableField(exist = false)
- @MPJMapping(tag = UserDO.class, thisField = "pid", joinField = "id")
+ @EntityMapping(thisField = "pid", joinField = "id")
private UserDO pUser;
/**
- * 一对多
+ * 查询下级 一对多
*/
@TableField(exist = false)
- @MPJMapping(tag = UserDO.class, thisField = "id", joinField = "pid")
- private List childUserList;
+ @EntityMapping(thisField = "id", joinField = "pid")
+ private List childUser;
+
+ /**
+ * 查询地址 (一对多)
+ */
+ @TableField(exist = false)
+ @EntityMapping(thisField = "id", joinField = "userId")
+ private List addressList;
+
+ /**
+ * 绑定字段 (一对多)
+ */
+ @TableField(exist = false)
+ @FieldMapping(tag = UserDO.class, thisField = "id", joinField = "pid", select = "id")
+ private List childIds;
}
```
@@ -87,11 +101,10 @@ class MappingTest {
* 第一次查询目标UserDO
* 第二次根据pid查询上级用户
* 第三次根据自身id查询下级用户
- *
*/
@Test
void test1() {
- UserDO deep = userMapper.selectByIdDeep(1);
+ UserDO deep = userMapper.selectByIdDeep(2);
System.out.println(deep);
}
@@ -103,7 +116,6 @@ class MappingTest {
* 第一次查询目标UserDO集合
* 第二次根据pid查询上级用户(不会一条记录一条记录的去查询,对pid进行汇总,用in语句一次性查出来,然后进行匹配)
* 第三次根据自身id查询下级用户(不会一条记录一条记录的去查询,对id进行汇总,用in语句一次性查出来,然后进行匹配)
- *
*/
@Test
void test2() {
@@ -122,9 +134,6 @@ class MappingTest {
page.getRecords().forEach(System.out::println);
}
-
-}
-
```
MPJMapping 说明:
diff --git a/pom.xml b/pom.xml
index d342399..bc8def3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
4.0.0
com.github.yulichang
mybatis-plus-join
- 1.2.0.Beta4
+ 1.2.0.Beta5
mybatis-plus-join
An enhanced toolkit of Mybatis-Plus to simplify development.
https://github.com/yulichang/mybatis-plus-join