Browse Source

mybatis 一对多 分步查询提交

zhang 2 years ago
parent
commit
e25692ad2a

+ 1 - 1
mybatis_train/src/main/java/com/mapper/AccountMapper.java

@@ -13,7 +13,7 @@ public interface AccountMapper {
13
     List<AccountEntity> findAll(Integer id);
13
     List<AccountEntity> findAll(Integer id);
14
     void updateOne(AccountEntity accountEntity);
14
     void updateOne(AccountEntity accountEntity);
15
     void insertOne(AccountEntity accountEntity);
15
     void insertOne(AccountEntity accountEntity);
16
-    AccountRealEntity findByDepId(Integer depId);
16
+    List<AccountRealEntity> findByDepId(Integer depId);
17
     // 多对一查询
17
     // 多对一查询
18
     AccountVO findVO(Integer id);
18
     AccountVO findVO(Integer id);
19
     AccountVO findByStep(Integer id);
19
     AccountVO findByStep(Integer id);

+ 1 - 0
mybatis_train/src/main/resources/com/mapper/DepartmentMapper.xml

@@ -18,6 +18,7 @@
18
         <result property="depName" column="dep_name"></result>
18
         <result property="depName" column="dep_name"></result>
19
         <collection property="accountEntities"
19
         <collection property="accountEntities"
20
                     select="com.mapper.AccountMapper.findByDepId"
20
                     select="com.mapper.AccountMapper.findByDepId"
21
+                    fetchType="lazy"
21
                     column="dep_id">
22
                     column="dep_id">
22
         </collection>
23
         </collection>
23
     </resultMap>
24
     </resultMap>