Mybatis Link(Mybatis Plus X)通过自定义注解方式,注入基础CRUD,一对一,一对多连表查询方法(2)

三. MyBatis Link 一对一,一对多连表查询配置,解析,结果展示

    本节通过一对一,一对多等连表查询进行注解配置,注解解析结果,以及查询结果进行展示。由于每张表生成的基础CRUD都是一样,且不需要进行手动配置,继而不在此处进行分析。    

    为了便于测试,先创建5张测试表,分别为t_test_a,t_test_b,t_test_c,t_test_d,t_test_e,下面将在TestADao中进行注解配置。

/**
 * <p>
 * 测试A
 * </p>
 *
 * @author yuyi (1060771195@qq.com)
 */
@Data
public class TestADto implements Serializable {
    private static final long serialVersionUID = 1L;

    protected TestAVo testAVo2;
    protected TestAVo testAVo;
    protected TestBVo testBVo;
    protected TestCVo testCVo;
    protected TestDVo testDVo;
    protected List<TestBDto> testBList;
    protected List<TestCDto> testCList;

}
/**
 * <p>
 * 测试A Mapper 接口
 * </p>
 *
 * @author yuyi (1060771195@qq.com)
 * @since 2019-03-20
 */
@Mapper
public interface TestADao extends BaseDao<TestAVo, TestADto> {

    /**
     * t_test_a 与 t_test_a 一对一连表查询
     * 由于两个表相同,所以必须给其中一个表设置表名,且该别名必须跟TestADto对象中得属性名对应,如:rightAlias = "testAVo2"
     * leftClass默认为TestAVo.class, 如果leftClass为TestAVo.class, 可以默认省略
     * leftColumn或者rightColumn都不写,默认为该表主键
     */
    @Link(  print = false, 
            ones = { @OneToOne(leftColumn = "a_id", rightClass = TestAVo.class, rightAlias = "testAVo2") })
    List<TestADto> listTestAATestA(@Param(Constants.WRAPPER) Wrapper<TestAVo> wrapper);
    
    /**
     * t_test_a 与   t_test_c 一对一连表查询
     */
    @Link(  print = false, 
            ones = { @OneToOne(leftColumn = "c_id", rightClass = TestCVo.class) })
    List<TestADto> listTestAATestC(@Param(Constants.WRAPPER) Wrapper<TestAVo> wrapper);
    
    /**
     * t_test_a 与   t_test_b 一对一连表查询
     */
    @Link(  print = false, 
            ones = { @OneToOne(rightClass = TestBVo.class, rightColumn = "a_id") })
    List<TestADto> listTestAATestB(@Param(Constants.WRAPPER) Wrapper<TestAVo> wrapper);
    
    /**
     * t_test_a 与  t_test_b, t_test_a 与  t_test_c 多表查询
     */
    @Link(  print = false, 
            ones = { @OneToOne(leftColumn = "b_id", rightClass = TestBVo.class),
                     @OneToOne(leftColumn = "c_id", rightClass = TestCVo.class)})
    List<TestADto> listTestAATestBATestC(@Param(Constants.WRAPPER) Wrapper<TestAVo> wrapper);
    
    /**
     * t_test_a 与  t_test_b, t_test_b 与  t_test_c, t_test_a 与  t_test_d 多表查询
     */
    @Link(  print = false, 
            ones = { @OneToOne(leftColumn = "b_id", rightClass = TestBVo.class),
                     @OneToOne(leftClass = TestBVo.class, leftColumn = "c_id", rightClass = TestCVo.class),
                     @OneToOne(rightClass = TestDVo.class, rightColumn = "a_id")})
    List<TestADto> listTestAATestBATestCATestD(@Param(Constants.WRAPPER) Wrapper<TestAVo> wrapper);
    
    /**
     * t_test_a 左连接 t_test_b
     */
    @Link(  print = false, 
            ones = { @OneToOne(leftColumn = "b_id", rightClass = TestBVo.class, joinType = JoinType.LEFT, onArgName = "abOn") })
    List<TestADto> listTestALtTestB(@Param(Constants.WRAPPER) Wrapper<TestAVo> wrapper);
    
    /**
     * t_test_a 左连接 t_test_b, t_test_a 左连接 t_test_c  
     */
    @Link(  print = false, 
            ones = { @OneToOne(leftColumn = "b_id", rightClass = TestBVo.class, joinType = JoinType.LEFT, onArgName = "abOn"), 
                     @OneToOne(leftColumn = "c_id", rightClass = TestCVo.class, joinType = JoinType.LEFT, onArgName = "acOn")})
    List<TestADto> listTestALtTestBLtTestC(@Param(Constants.WRAPPER) Wrapper<TestAVo> wrapper);
    
    /**
     * t_test_a 右连接 t_test_c
     */
    @Link(  print = false, 
            ones = { @OneToOne(leftColumn = "b_id", rightClass = TestCVo.class, joinType = JoinType.RIGHT, onArgName = "acOn") })
    List<TestADto> listTestARtTestC(@Param(Constants.WRAPPER) Wrapper<TestAVo> wrapper);
    
    /**
     * t_test_a 一对多 t_test_b
     * 如果t_test_b对应得rightClass 为约定得  TestBVo.class, 可以缺省
     * 由于TestADto中对应得属性List<TestBDto> testBList 这种类型property 对应的是该属性属性名
     */
    @Link(  print = false, 
            manys = { @OneToMany(leftColumn = "b_id", rightClass = TestBVo.class, ofTypeClass = TestBDto.class, property = "testBList") })
    List<TestADto> listTestAWTestB(@Param(Constants.WRAPPER) Wrapper<TestAVo> wrapper);
    
    /**
    * t_test_a 一对多 t_test_b, t_test_a 一对多 t_test_c
    */
   @Link(  print = false, printRm = true,
           manys = { @OneToMany(leftColumn = "b_id", rightClass = TestBVo.class, ofTypeClass = TestBDto.class, property = "testBList"),
                     @OneToMany(leftColumn = "c_id", rightClass = TestCVo.class, ofTypeClass = TestCDto.class, property = "testCList")})
   List<TestADto> listTestAWTestBWTestC(@Param(Constants.WRAPPER) Wrapper<TestAVo> wrapper);
    
    /**
     * t_test_a 一对一  t_test_b, t_test_a 一对多 t_test_b
     */
    @Link(  print = false, printRm = false,
            ones = { @OneToOne(leftColumn = "b_id", rightClass = TestBVo.class)},
            manys = { @OneToMany(leftClass = TestAVo.class, leftColumn = "b_id", rightClass = TestBVo.class, ofTypeClass = TestBDto.class, property = "testBList") })
    List<TestADto> listTestAATestBWTestB(@Param(Constants.WRAPPER) Wrapper<TestAVo> wrapper);
    
    /**
     * t_test_a 一对一  t_test_b, t_test_a 一对多 t_test_b, 多表中 t_test_b 一对一 t_test_c
     */
    @Link(  print = false, 
            ones = { @OneToOne(leftColumn = "b_id", rightClass = TestBVo.class)},
            manys = { @OneToMany(leftClass = TestAVo.class, leftColumn = "b_id", rightClass = TestBVo.class, ofTypeClass = TestBDto.class, property = "testBList", 
            ones = { @OneToOne(leftColumn = "c_id", rightClass = TestCVo.class)} )})
    List<TestADto> listTestAATestBWTestBATestC(@Param(Constants.WRAPPER) Wrapper<TestAVo> wrapper);
    
    /**
     * t_test_a 与   t_test_b 一对一分页连表查询
     */
    @Link(  print = false, 
            ones = { @OneToOne(rightClass = TestBVo.class, rightColumn = "a_id") })
    IPage<TestADto> pageTestAATestB(IPage<TestADto> page, @Param(Constants.WRAPPER) Wrapper<TestAVo> wrapper);
    
    /**
     * t_test_a 与   t_test_b 连表行数查询
     */
    @Link(  print = false, 
            ones = { @OneToOne(rightClass = TestBVo.class, rightColumn = "a_id") })
    Integer countTestAATestB(@Param(Constants.WRAPPER) Wrapper<TestAVo> wrapper);
    
}

  下面将对TestADao中关键注解进行解析结果展示和查询结果展示

/**
     * t_test_a 与 t_test_a 一对一连表查询
     * 由于两个表相同,所以必须给其中一个表设置表名,且该别名必须跟TestADto对象中得属性名对应,如:rightAlias = "testAVo2"
     * leftClass默认为TestAVo.class, 如果leftClass为TestAVo.class, 可以默认省略
     * leftColumn或者rightColumn都不写,默认为该表主键
     */
    @Link(  print = false, 
            ones = { @OneToOne(leftColumn = "a_id", rightClass = TestAVo.class, 
            rightAlias = "testAVo2") })
    List<TestADto> listTestAATestA(@Param(Constants.WRAPPER) Wrapper<TestAVo> wrapper);
<resultMap id="yui.bss.test.dao.TestADao.listTestAATestA-ResultMap" type="class yui.bss.test.dto.TestADto">
    <result property="testAVo.id" column="t_test_a__id" jdbcType="class java.lang.Long"/>
    <result property="testAVo.cId" column="t_test_a__c_id" jdbcType="class java.lang.Long"/>
    <result property="testAVo.bId" column="t_test_a__b_id" jdbcType="class java.lang.Long"/>
    <result property="testAVo.aId" column="t_test_a__a_id" jdbcType="class java.lang.Long"/>
    <result property="testAVo.crtTm" column="t_test_a__crt_tm" jdbcType="class java.util.Date"/>
    <result property="testAVo.crtBy" column="t_test_a__crt_by" jdbcType="class java.lang.String"/>
    <result property="testAVo.updTm" column="t_test_a__upd_tm" jdbcType="class java.util.Date"/>
    <result property="testAVo.updBy" column="t_test_a__upd_by" jdbcType="class java.lang.String"/>
    <result property="testAVo.editFlag" column="t_test_a__edit_flag" jdbcType="class java.lang.Integer"/>
    <result property="testAVo.tntId" column="t_test_a__tnt_id" jdbcType="class java.lang.Long"/>
    <result property="testAVo2.id" column="testAVo2__id" jdbcType="class java.lang.Long"/>
    <result property="testAVo2.cId" column="testAVo2__cId" jdbcType="class java.lang.Long"/>
    <result property="testAVo2.bId" column="testAVo2__bId" jdbcType="class java.lang.Long"/>
    <result property="testAVo2.aId" column="testAVo2__aId" jdbcType="class java.lang.Long"/>
    <result property="testAVo2.crtTm" column="testAVo2__crtTm" jdbcType="class java.util.Date"/>
    <result property="testAVo2.crtBy" column="testAVo2__crtBy" jdbcType="class java.lang.String"/>
    <result property="testAVo2.updTm" column="testAVo2__updTm" jdbcType="class java.util.Date"/>
    <result property="testAVo2.updBy" column="testAVo2__updBy" jdbcType="class java.lang.String"/>
    <result property="testAVo2.editFlag" column="testAVo2__editFlag" jdbcType="class java.lang.Integer"/>
    <result property="testAVo2.tntId" column="testAVo2__tntId" jdbcType="class java.lang.Long"/>
</resultMap>
<script>
SELECT <choose>
<when test="ew != null and ew.sqlSelect != null">
${ew.sqlSelect}
</when>
<otherwise> t_test_a.`id` t_test_a__id , t_test_a.`c_id` t_test_a__c_id , t_test_a.`b_id` t_test_a__b_id , t_test_a.`a_id` t_test_a__a_id , t_test_a.`crt_tm` t_test_a__crt_tm , t_test_a.`crt_by` t_test_a__crt_by , t_test_a.`upd_tm` t_test_a__upd_tm , t_test_a.`upd_by` t_test_a__upd_by , t_test_a.`edit_flag` t_test_a__edit_flag , t_test_a.`tnt_id` t_test_a__tnt_id , testAVo2.`id` testAVo2__id , testAVo2.`c_id` testAVo2__c_id , testAVo2.`b_id` testAVo2__b_id , testAVo2.`a_id` testAVo2__a_id , testAVo2.`crt_tm` testAVo2__crt_tm , testAVo2.`crt_by` testAVo2__crt_by , testAVo2.`upd_tm` testAVo2__upd_tm , testAVo2.`upd_by` testAVo2__upd_by , testAVo2.`edit_flag` testAVo2__edit_flag , testAVo2.`tnt_id` testAVo2__tnt_id </otherwise>
</choose> FROM t_test_a t_test_a INNER JOIN t_test_a testAVo2 <trim prefix="WHERE" prefixOverrides="AND|OR">
 AND t_test_a.edit_flag=0 AND testAVo2.edit_flag=0 and t_test_a.a_id=testAVo2.id
<if test="ew != null">
<if test="ew.id != null">
 AND t_test_a.id = ${ew.id}
</if>
<if test="ew.sqlSegment != null and ew.sqlSegment != '' and ew.nonEmptyOfWhere">
 AND ${ew.sqlSegment}
</if>
<if test="ew.sqlSegment != null and ew.sqlSegment != '' and ew.emptyOfWhere">
 ${ew.sqlSegment}
</if>
</if>
</trim>
</script>
{
  "code": 0,
  "data": {
    "list": [
      {
        "testAVo2": {
          "crtTm": null,
          "crtBy": null,
          "updTm": null,
          "updBy": null,
          "editFlag": null,
          "tntId": null,
          "id": 1,
          "cid": null,
          "aid": null,
          "bid": null
        },
        "testAVo": {
          "crtTm": null,
          "crtBy": null,
          "updTm": null,
          "updBy": null,
          "editFlag": 0,
          "tntId": null,
          "id": 2,
          "cid": 1,
          "aid": 1,
          "bid": 1
        },
        "testBVo": null,
        "testCVo": null,
        "testDVo": null,
        "testBList": null,
        "testCList": null
      }
    ]
  }
}
/**
     * t_test_a 与   t_test_c 一对一连表查询
     */
    @Link(  print = true, printRm = true,
            ones = { @OneToOne(leftColumn = "c_id", rightClass = TestCVo.class) })
    List<TestADto> listTestAATestC(@Param(Constants.WRAPPER) Wrapper<TestAVo> wrapper);
<resultMap id="yui.bss.test.dao.TestADao.listTestAATestC-ResultMap" type="class yui.bss.test.dto.TestADto">
    <result property="testAVo.id" column="t_test_a__id" jdbcType="class java.lang.Long"/>
    <result property="testAVo.cId" column="t_test_a__c_id" jdbcType="class java.lang.Long"/>
    <result property="testAVo.bId" column="t_test_a__b_id" jdbcType="class java.lang.Long"/>
    <result property="testAVo.aId" column="t_test_a__a_id" jdbcType="class java.lang.Long"/>
    <result property="testAVo.crtTm" column="t_test_a__crt_tm" jdbcType="class java.util.Date"/>
    <result property="testAVo.crtBy" column="t_test_a__crt_by" jdbcType="class java.lang.String"/>
    <result property="testAVo.updTm" column="t_test_a__upd_tm" jdbcType="class java.util.Date"/>
    <result property="testAVo.updBy" column="t_test_a__upd_by" jdbcType="class java.lang.String"/>
    <result property="testAVo.editFlag" column="t_test_a__edit_flag" jdbcType="class java.lang.Integer"/>
    <result property="testAVo.tntId" column="t_test_a__tnt_id" jdbcType="class java.lang.Long"/>
    <result property="testCVo.id" column="t_test_c__id" jdbcType="class java.lang.Long"/>
    <result property="testCVo.aId" column="t_test_c__a_id" jdbcType="class java.lang.Long"/>
    <result property="testCVo.bId" column="t_test_c__b_id" jdbcType="class java.lang.Long"/>
    <result property="testCVo.cId" column="t_test_c__c_id" jdbcType="class java.lang.Long"/>
    <result property="testCVo.crtTm" column="t_test_c__crt_tm" jdbcType="class java.util.Date"/>
    <result property="testCVo.crtBy" column="t_test_c__crt_by" jdbcType="class java.lang.String"/>
    <result property="testCVo.updTm" column="t_test_c__upd_tm" jdbcType="class java.util.Date"/>
    <result property="testCVo.updBy" column="t_test_c__upd_by" jdbcType="class java.lang.String"/>
    <result property="testCVo.editFlag" column="t_test_c__edit_flag" jdbcType="class java.lang.Integer"/>
    <result property="testCVo.tntId" column="t_test_c__tnt_id" jdbcType="class java.lang.Long"/>
</resultMap>
<script>
SELECT <choose>
<when test="ew != null and ew.sqlSelect != null">
${ew.sqlSelect}
</when>
<otherwise> t_test_a.`id` t_test_a__id , t_test_a.`c_id` t_test_a__c_id , t_test_a.`b_id` t_test_a__b_id , t_test_a.`a_id` t_test_a__a_id , t_test_a.`crt_tm` t_test_a__crt_tm , t_test_a.`crt_by` t_test_a__crt_by , t_test_a.`upd_tm` t_test_a__upd_tm , t_test_a.`upd_by` t_test_a__upd_by , t_test_a.`edit_flag` t_test_a__edit_flag , t_test_a.`tnt_id` t_test_a__tnt_id , t_test_c.`id` t_test_c__id , t_test_c.`a_id` t_test_c__a_id , t_test_c.`b_id` t_test_c__b_id , t_test_c.`c_id` t_test_c__c_id , t_test_c.`crt_tm` t_test_c__crt_tm , t_test_c.`crt_by` t_test_c__crt_by , t_test_c.`upd_tm` t_test_c__upd_tm , t_test_c.`upd_by` t_test_c__upd_by , t_test_c.`edit_flag` t_test_c__edit_flag , t_test_c.`tnt_id` t_test_c__tnt_id </otherwise>
</choose> FROM t_test_a t_test_a INNER JOIN t_test_c t_test_c <trim prefix="WHERE" prefixOverrides="AND|OR">
 AND t_test_a.edit_flag=0 AND t_test_c.edit_flag=0 and t_test_a.c_id=t_test_c.id
<if test="ew != null">
<if test="ew.id != null">
 AND t_test_a.id = ${ew.id}
</if>
<if test="ew.sqlSegment != null and ew.sqlSegment != '' and ew.nonEmptyOfWhere">
 AND ${ew.sqlSegment}
</if>
<if test="ew.sqlSegment != null and ew.sqlSegment != '' and ew.emptyOfWhere">
 ${ew.sqlSegment}
</if>
</if>
</trim>
</script>
{
  "code": 0,
  "data": {
    "list": [
      {
        "testAVo2": null,
        "testAVo": {
          "crtTm": "2017-11-07 15:17:11",
          "crtBy": null,
          "updTm": "2018-12-18 02:30:11",
          "updBy": "admin",
          "editFlag": 0,
          "tntId": null,
          "id": 1,
          "cid": 1,
          "aid": null,
          "bid": 1
        },
        "testBVo": null,
        "testCVo": {
          "crtTm": "2017-11-07 15:17:11",
          "crtBy": null,
          "updTm": "2018-12-18 02:30:11",
          "updBy": "admin",
          "editFlag": 0,
          "tntId": null,
          "id": 1,
          "cid": 1,
          "aid": 1,
          "bid": 1
        },
        "testDVo": null,
        "testBList": null,
        "testCList": null
      },
      {
        "testAVo2": null,
        "testAVo": {
          "crtTm": null,
          "crtBy": null,
          "updTm": null,
          "updBy": null,
          "editFlag": 0,
          "tntId": null,
          "id": 2,
          "cid": 1,
          "aid": 1,
          "bid": 1
        },
        "testBVo": null,
        "testCVo": {
          "crtTm": "2017-11-07 15:17:11",
          "crtBy": null,
          "updTm": "2018-12-18 02:30:11",
          "updBy": "admin",
          "editFlag": 0,
          "tntId": null,
          "id": 1,
          "cid": 1,
          "aid": 1,
          "bid": 1
        },
        "testDVo": null,
        "testBList": null,
        "testCList": null
      }
    ]
  }
}
/**
     * t_test_a 与   t_test_b 一对一连表查询
     */
    @Link(  print = true, printRm = true,
            ones = { @OneToOne(rightClass = TestBVo.class, rightColumn = "a_id") })
    List<TestADto> listTestAATestB(@Param(Constants.WRAPPER) Wrapper<TestAVo> wrapper);
<script>
SELECT <choose>
<when test="ew != null and ew.sqlSelect != null">
${ew.sqlSelect}
</when>
<otherwise> t_test_a.`id` t_test_a__id , t_test_a.`c_id` t_test_a__c_id , t_test_a.`b_id` t_test_a__b_id , t_test_a.`a_id` t_test_a__a_id , t_test_a.`crt_tm` t_test_a__crt_tm , t_test_a.`crt_by` t_test_a__crt_by , t_test_a.`upd_tm` t_test_a__upd_tm , t_test_a.`upd_by` t_test_a__upd_by , t_test_a.`edit_flag` t_test_a__edit_flag , t_test_a.`tnt_id` t_test_a__tnt_id , t_test_b.`id` t_test_b__id , t_test_b.`a_id` t_test_b__a_id , t_test_b.`c_id` t_test_b__c_id , t_test_b.`crt_tm` t_test_b__crt_tm , t_test_b.`crt_by` t_test_b__crt_by , t_test_b.`upd_tm` t_test_b__upd_tm , t_test_b.`upd_by` t_test_b__upd_by , t_test_b.`edit_flag` t_test_b__edit_flag , t_test_b.`tnt_id` t_test_b__tnt_id </otherwise>
</choose> FROM t_test_a t_test_a INNER JOIN t_test_b t_test_b <trim prefix="WHERE" prefixOverrides="AND|OR">
 AND t_test_a.edit_flag=0 AND t_test_b.edit_flag=0 and t_test_a.id=t_test_b.a_id
<if test="ew != null">
<if test="ew.id != null">
 AND t_test_a.id = ${ew.id}
</if>
<if test="ew.sqlSegment != null and ew.sqlSegment != '' and ew.nonEmptyOfWhere">
 AND ${ew.sqlSegment}
</if>
<if test="ew.sqlSegment != null and ew.sqlSegment != '' and ew.emptyOfWhere">
 ${ew.sqlSegment}
</if>
</if>
</trim>
</script>
/**
     * t_test_a 与  t_test_b, t_test_a 与  t_test_c 多表查询
     */
    @Link(  print = true, printRm = true,
            ones = { @OneToOne(leftColumn = "b_id", rightClass = TestBVo.class),
                     @OneToOne(leftColumn = "c_id", rightClass = TestCVo.class)})
    List<TestADto> listTestAATestBATestC(@Param(Constants.WRAPPER) Wrapper<TestAVo> wrapper);
<script>
SELECT <choose>
<when test="ew != null and ew.sqlSelect != null">
${ew.sqlSelect}
</when>
<otherwise> t_test_a.`id` t_test_a__id , t_test_a.`c_id` t_test_a__c_id , t_test_a.`b_id` t_test_a__b_id , t_test_a.`a_id` t_test_a__a_id , t_test_a.`crt_tm` t_test_a__crt_tm , t_test_a.`crt_by` t_test_a__crt_by , t_test_a.`upd_tm` t_test_a__upd_tm , t_test_a.`upd_by` t_test_a__upd_by , t_test_a.`edit_flag` t_test_a__edit_flag , t_test_a.`tnt_id` t_test_a__tnt_id , t_test_b.`id` t_test_b__id , t_test_b.`a_id` t_test_b__a_id , t_test_b.`c_id` t_test_b__c_id , t_test_b.`crt_tm` t_test_b__crt_tm , t_test_b.`crt_by` t_test_b__crt_by , t_test_b.`upd_tm` t_test_b__upd_tm , t_test_b.`upd_by` t_test_b__upd_by , t_test_b.`edit_flag` t_test_b__edit_flag , t_test_b.`tnt_id` t_test_b__tnt_id , t_test_c.`id` t_test_c__id , t_test_c.`a_id` t_test_c__a_id , t_test_c.`b_id` t_test_c__b_id , t_test_c.`c_id` t_test_c__c_id , t_test_c.`crt_tm` t_test_c__crt_tm , t_test_c.`crt_by` t_test_c__crt_by , t_test_c.`upd_tm` t_test_c__upd_tm , t_test_c.`upd_by` t_test_c__upd_by , t_test_c.`edit_flag` t_test_c__edit_flag , t_test_c.`tnt_id` t_test_c__tnt_id </otherwise>
</choose> FROM t_test_a t_test_a INNER JOIN t_test_b t_test_b INNER JOIN t_test_c t_test_c <trim prefix="WHERE" prefixOverrides="AND|OR">
 AND t_test_a.edit_flag=0 AND t_test_b.edit_flag=0 and t_test_a.b_id=t_test_b.id AND t_test_c.edit_flag=0 and t_test_a.c_id=t_test_c.id
<if test="ew != null">
<if test="ew.id != null">
 AND t_test_a.id = ${ew.id}
</if>
<if test="ew.sqlSegment != null and ew.sqlSegment != '' and ew.nonEmptyOfWhere">
 AND ${ew.sqlSegment}
</if>
<if test="ew.sqlSegment != null and ew.sqlSegment != '' and ew.emptyOfWhere">
 ${ew.sqlSegment}
</if>
</if>
</trim>
</script>
/**
     * t_test_a 与  t_test_b, t_test_b 与  t_test_c, t_test_a 与  t_test_d 多表查询
     */
    @Link(  print = true, printRm = true,
            ones = { @OneToOne(leftColumn = "b_id", rightClass = TestBVo.class),
                     @OneToOne(leftClass = TestBVo.class, leftColumn = "c_id", rightClass = TestCVo.class),
                     @OneToOne(rightClass = TestDVo.class, rightColumn = "a_id")})
    List<TestADto> listTestAATestBATestCATestD(@Param(Constants.WRAPPER) Wrapper<TestAVo> wrapper);
<script>
SELECT <choose>
<when test="ew != null and ew.sqlSelect != null">
${ew.sqlSelect}
</when>
<otherwise> t_test_a.`id` t_test_a__id , t_test_a.`c_id` t_test_a__c_id , t_test_a.`b_id` t_test_a__b_id , t_test_a.`a_id` t_test_a__a_id , t_test_a.`crt_tm` t_test_a__crt_tm , t_test_a.`crt_by` t_test_a__crt_by , t_test_a.`upd_tm` t_test_a__upd_tm , t_test_a.`upd_by` t_test_a__upd_by , t_test_a.`edit_flag` t_test_a__edit_flag , t_test_a.`tnt_id` t_test_a__tnt_id , t_test_b.`id` t_test_b__id , t_test_b.`a_id` t_test_b__a_id , t_test_b.`c_id` t_test_b__c_id , t_test_b.`crt_tm` t_test_b__crt_tm , t_test_b.`crt_by` t_test_b__crt_by , t_test_b.`upd_tm` t_test_b__upd_tm , t_test_b.`upd_by` t_test_b__upd_by , t_test_b.`edit_flag` t_test_b__edit_flag , t_test_b.`tnt_id` t_test_b__tnt_id , t_test_c.`id` t_test_c__id , t_test_c.`a_id` t_test_c__a_id , t_test_c.`b_id` t_test_c__b_id , t_test_c.`c_id` t_test_c__c_id , t_test_c.`crt_tm` t_test_c__crt_tm , t_test_c.`crt_by` t_test_c__crt_by , t_test_c.`upd_tm` t_test_c__upd_tm , t_test_c.`upd_by` t_test_c__upd_by , t_test_c.`edit_flag` t_test_c__edit_flag , t_test_c.`tnt_id` t_test_c__tnt_id , t_test_d.`id` t_test_d__id , t_test_d.`a_id` t_test_d__a_id , t_test_d.`crt_tm` t_test_d__crt_tm , t_test_d.`crt_by` t_test_d__crt_by , t_test_d.`upd_tm` t_test_d__upd_tm , t_test_d.`upd_by` t_test_d__upd_by , t_test_d.`edit_flag` t_test_d__edit_flag , t_test_d.`tnt_id` t_test_d__tnt_id </otherwise>
</choose> FROM t_test_a t_test_a INNER JOIN t_test_b t_test_b INNER JOIN t_test_c t_test_c INNER JOIN t_test_d t_test_d <trim prefix="WHERE" prefixOverrides="AND|OR">
 AND t_test_a.edit_flag=0 AND t_test_b.edit_flag=0 and t_test_a.b_id=t_test_b.id AND t_test_c.edit_flag=0 and t_test_b.c_id=t_test_c.id AND t_test_d.edit_flag=0 and t_test_a.id=t_test_d.a_id
<if test="ew != null">
<if test="ew.id != null">
 AND t_test_a.id = ${ew.id}
</if>
<if test="ew.sqlSegment != null and ew.sqlSegment != '' and ew.nonEmptyOfWhere">
 AND ${ew.sqlSegment}
</if>
<if test="ew.sqlSegment != null and ew.sqlSegment != '' and ew.emptyOfWhere">
 ${ew.sqlSegment}
</if>
</if>
</trim>
</script>
/**
     * t_test_a 左连接 t_test_b
     */
    @Link(  print = true, printRm = true,
            ones = { @OneToOne(leftColumn = "b_id", rightClass = TestBVo.class, joinType = JoinType.LEFT, onArgName = "abOn") })
    List<TestADto> listTestALtTestB(@Param(Constants.WRAPPER) Wrapper<TestAVo> wrapper);
<script>
SELECT <choose>
<when test="ew != null and ew.sqlSelect != null">
${ew.sqlSelect}
</when>
<otherwise> t_test_a.`id` t_test_a__id , t_test_a.`c_id` t_test_a__c_id , t_test_a.`b_id` t_test_a__b_id , t_test_a.`a_id` t_test_a__a_id , t_test_a.`crt_tm` t_test_a__crt_tm , t_test_a.`crt_by` t_test_a__crt_by , t_test_a.`upd_tm` t_test_a__upd_tm , t_test_a.`upd_by` t_test_a__upd_by , t_test_a.`edit_flag` t_test_a__edit_flag , t_test_a.`tnt_id` t_test_a__tnt_id , t_test_b.`id` t_test_b__id , t_test_b.`a_id` t_test_b__a_id , t_test_b.`c_id` t_test_b__c_id , t_test_b.`crt_tm` t_test_b__crt_tm , t_test_b.`crt_by` t_test_b__crt_by , t_test_b.`upd_tm` t_test_b__upd_tm , t_test_b.`upd_by` t_test_b__upd_by , t_test_b.`edit_flag` t_test_b__edit_flag , t_test_b.`tnt_id` t_test_b__tnt_id </otherwise>
</choose> FROM t_test_a t_test_a LEFT JOIN t_test_b t_test_b on t_test_a.b_id=t_test_b.id AND t_test_b.edit_flag=0 <if test="ew != null and ew.sqlOnMap != null and ew.sqlOnMap.abOn != null and ew.sqlOnMap.abOn != ''">
 AND ${ew.sqlOnMap.abOn}
</if> <trim prefix="WHERE" prefixOverrides="AND|OR">
 AND t_test_a.edit_flag=0
<if test="ew != null">
<if test="ew.id != null">
 AND t_test_a.id = ${ew.id}
</if>
<if test="ew.sqlSegment != null and ew.sqlSegment != '' and ew.nonEmptyOfWhere">
 AND ${ew.sqlSegment}
</if>
<if test="ew.sqlSegment != null and ew.sqlSegment != '' and ew.emptyOfWhere">
 ${ew.sqlSegment}
</if>
</if>
</trim>
</script>
/**
     * t_test_a 左连接 t_test_b, t_test_a 左连接 t_test_c  
     */
    @Link(  print = true, printRm = true,
            ones = { @OneToOne(leftColumn = "b_id", rightClass = TestBVo.class, joinType = JoinType.LEFT, onArgName = "abOn"), 
                     @OneToOne(leftColumn = "c_id", rightClass = TestCVo.class, joinType = JoinType.LEFT, onArgName = "acOn")})
    List<TestADto> listTestALtTestBLtTestC(@Param(Constants.WRAPPER) Wrapper<TestAVo> wrapper);
<script>
SELECT <choose>
<when test="ew != null and ew.sqlSelect != null">
${ew.sqlSelect}
</when>
<otherwise> t_test_a.`id` t_test_a__id , t_test_a.`c_id` t_test_a__c_id , t_test_a.`b_id` t_test_a__b_id , t_test_a.`a_id` t_test_a__a_id , t_test_a.`crt_tm` t_test_a__crt_tm , t_test_a.`crt_by` t_test_a__crt_by , t_test_a.`upd_tm` t_test_a__upd_tm , t_test_a.`upd_by` t_test_a__upd_by , t_test_a.`edit_flag` t_test_a__edit_flag , t_test_a.`tnt_id` t_test_a__tnt_id , t_test_b.`id` t_test_b__id , t_test_b.`a_id` t_test_b__a_id , t_test_b.`c_id` t_test_b__c_id , t_test_b.`crt_tm` t_test_b__crt_tm , t_test_b.`crt_by` t_test_b__crt_by , t_test_b.`upd_tm` t_test_b__upd_tm , t_test_b.`upd_by` t_test_b__upd_by , t_test_b.`edit_flag` t_test_b__edit_flag , t_test_b.`tnt_id` t_test_b__tnt_id , t_test_c.`id` t_test_c__id , t_test_c.`a_id` t_test_c__a_id , t_test_c.`b_id` t_test_c__b_id , t_test_c.`c_id` t_test_c__c_id , t_test_c.`crt_tm` t_test_c__crt_tm , t_test_c.`crt_by` t_test_c__crt_by , t_test_c.`upd_tm` t_test_c__upd_tm , t_test_c.`upd_by` t_test_c__upd_by , t_test_c.`edit_flag` t_test_c__edit_flag , t_test_c.`tnt_id` t_test_c__tnt_id </otherwise>
</choose> FROM t_test_a t_test_a LEFT JOIN t_test_b t_test_b on t_test_a.b_id=t_test_b.id AND t_test_b.edit_flag=0 <if test="ew != null and ew.sqlOnMap != null and ew.sqlOnMap.abOn != null and ew.sqlOnMap.abOn != ''">
 AND ${ew.sqlOnMap.abOn}
</if> LEFT JOIN t_test_c t_test_c on t_test_a.c_id=t_test_c.id AND t_test_c.edit_flag=0 <if test="ew != null and ew.sqlOnMap != null and ew.sqlOnMap.acOn != null and ew.sqlOnMap.acOn != ''">
 AND ${ew.sqlOnMap.acOn}
</if> <trim prefix="WHERE" prefixOverrides="AND|OR">
 AND t_test_a.edit_flag=0
<if test="ew != null">
<if test="ew.id != null">
 AND t_test_a.id = ${ew.id}
</if>
<if test="ew.sqlSegment != null and ew.sqlSegment != '' and ew.nonEmptyOfWhere">
 AND ${ew.sqlSegment}
</if>
<if test="ew.sqlSegment != null and ew.sqlSegment != '' and ew.emptyOfWhere">
 ${ew.sqlSegment}
</if>
</if>
</trim>
</script>
/**
     * t_test_a 右连接 t_test_c
     */
    @Link(  print = true, printRm = true,
            ones = { @OneToOne(leftColumn = "b_id", rightClass = TestCVo.class, joinType = JoinType.RIGHT, onArgName = "acOn") })
    List<TestADto> listTestARtTestC(@Param(Constants.WRAPPER) Wrapper<TestAVo> wrapper);
<script>
SELECT <choose>
<when test="ew != null and ew.sqlSelect != null">
${ew.sqlSelect}
</when>
<otherwise> t_test_a.`id` t_test_a__id , t_test_a.`c_id` t_test_a__c_id , t_test_a.`b_id` t_test_a__b_id , t_test_a.`a_id` t_test_a__a_id , t_test_a.`crt_tm` t_test_a__crt_tm , t_test_a.`crt_by` t_test_a__crt_by , t_test_a.`upd_tm` t_test_a__upd_tm , t_test_a.`upd_by` t_test_a__upd_by , t_test_a.`edit_flag` t_test_a__edit_flag , t_test_a.`tnt_id` t_test_a__tnt_id , t_test_c.`id` t_test_c__id , t_test_c.`a_id` t_test_c__a_id , t_test_c.`b_id` t_test_c__b_id , t_test_c.`c_id` t_test_c__c_id , t_test_c.`crt_tm` t_test_c__crt_tm , t_test_c.`crt_by` t_test_c__crt_by , t_test_c.`upd_tm` t_test_c__upd_tm , t_test_c.`upd_by` t_test_c__upd_by , t_test_c.`edit_flag` t_test_c__edit_flag , t_test_c.`tnt_id` t_test_c__tnt_id </otherwise>
</choose> FROM t_test_a t_test_a RIGHT JOIN t_test_c t_test_c on t_test_a.b_id=t_test_c.id AND t_test_a.edit_flag=0 <if test="ew != null and ew.sqlOnMap != null and ew.sqlOnMap.acOn != null and ew.sqlOnMap.acOn != ''">
 AND ${ew.sqlOnMap.acOn}
</if> <trim prefix="WHERE" prefixOverrides="AND|OR">
 AND t_test_c.edit_flag=0
<if test="ew != null">
<if test="ew.id != null">
 AND t_test_a.id = ${ew.id}
</if>
<if test="ew.sqlSegment != null and ew.sqlSegment != '' and ew.nonEmptyOfWhere">
 AND ${ew.sqlSegment}
</if>
<if test="ew.sqlSegment != null and ew.sqlSegment != '' and ew.emptyOfWhere">
 ${ew.sqlSegment}
</if>
</if>
</trim>
</script>
/**
     * t_test_a 一对多 t_test_b
     * 如果t_test_b对应得rightClass 为约定得  TestBVo.class, 可以缺省
     * 由于TestADto中对应得属性List<TestBDto> testBList 这种类型property 对应的是该属性属性名
     */
    @Link(  print = true, printRm = true,
            manys = { @OneToMany(leftColumn = "b_id", rightClass = TestBVo.class, ofTypeClass = TestBDto.class, property = "testBList") })
    List<TestADto> listTestAWTestB(@Param(Constants.WRAPPER) Wrapper<TestAVo> wrapper);
<resultMap id="yui.bss.test.dao.TestADao.listTestAWTestB-ResultMap" type="class yui.bss.test.dto.TestADto">
    <result property="testAVo.id" column="t_test_a__id" jdbcType="class java.lang.Long"/>
    <result property="testAVo.cId" column="t_test_a__c_id" jdbcType="class java.lang.Long"/>
    <result property="testAVo.bId" column="t_test_a__b_id" jdbcType="class java.lang.Long"/>
    <result property="testAVo.aId" column="t_test_a__a_id" jdbcType="class java.lang.Long"/>
    <result property="testAVo.crtTm" column="t_test_a__crt_tm" jdbcType="class java.util.Date"/>
    <result property="testAVo.crtBy" column="t_test_a__crt_by" jdbcType="class java.lang.String"/>
    <result property="testAVo.updTm" column="t_test_a__upd_tm" jdbcType="class java.util.Date"/>
    <result property="testAVo.updBy" column="t_test_a__upd_by" jdbcType="class java.lang.String"/>
    <result property="testAVo.editFlag" column="t_test_a__edit_flag" jdbcType="class java.lang.Integer"/>
    <result property="testAVo.tntId" column="t_test_a__tnt_id" jdbcType="class java.lang.Long"/>
    <collection property="testBList" column="t_test_a__b_id" ofType="interface java.util.List" select="yui.bss.test.dao.TestADao._listTestAWTestB_testBList"/>
</resultMap>
<resultMap id="yui.bss.test.dao.TestADao._listTestAWTestB_testBList-ResultMap" type="class yui.bss.test.dto.TestBDto">
    <result property="testBVo.id" column="t_test_b__id" jdbcType="class java.lang.Long"/>
    <result property="testBVo.aId" column="t_test_b__a_id" jdbcType="class java.lang.Long"/>
    <result property="testBVo.cId" column="t_test_b__c_id" jdbcType="class java.lang.Long"/>
    <result property="testBVo.crtTm" column="t_test_b__crt_tm" jdbcType="class java.util.Date"/>
    <result property="testBVo.crtBy" column="t_test_b__crt_by" jdbcType="class java.lang.String"/>
    <result property="testBVo.updTm" column="t_test_b__upd_tm" jdbcType="class java.util.Date"/>
    <result property="testBVo.updBy" column="t_test_b__upd_by" jdbcType="class java.lang.String"/>
    <result property="testBVo.editFlag" column="t_test_b__edit_flag" jdbcType="class java.lang.Integer"/>
    <result property="testBVo.tntId" column="t_test_b__tnt_id" jdbcType="class java.lang.Long"/>
</resultMap>
<script>
SELECT <choose>
<when test="ew != null and ew.sqlSelect != null">
${ew.sqlSelect}
</when>
<otherwise> t_test_a.`id` t_test_a__id , t_test_a.`c_id` t_test_a__c_id , t_test_a.`b_id` t_test_a__b_id , t_test_a.`a_id` t_test_a__a_id , t_test_a.`crt_tm` t_test_a__crt_tm , t_test_a.`crt_by` t_test_a__crt_by , t_test_a.`upd_tm` t_test_a__upd_tm , t_test_a.`upd_by` t_test_a__upd_by , t_test_a.`edit_flag` t_test_a__edit_flag , t_test_a.`tnt_id` t_test_a__tnt_id </otherwise>
</choose> FROM t_test_a t_test_a <trim prefix="WHERE" prefixOverrides="AND|OR">
 AND t_test_a.edit_flag=0
<if test="ew != null">
<if test="ew.id != null">
 AND t_test_a.id = ${ew.id}
</if>
<if test="ew.sqlSegment != null and ew.sqlSegment != '' and ew.nonEmptyOfWhere">
 AND ${ew.sqlSegment}
</if>
<if test="ew.sqlSegment != null and ew.sqlSegment != '' and ew.emptyOfWhere">
 ${ew.sqlSegment}
</if>
</if>
</trim>
</script>
<script>
SELECT  t_test_b.`id` t_test_b__id , t_test_b.`a_id` t_test_b__a_id , t_test_b.`c_id` t_test_b__c_id , t_test_b.`crt_tm` t_test_b__crt_tm , t_test_b.`crt_by` t_test_b__crt_by , t_test_b.`upd_tm` t_test_b__upd_tm , t_test_b.`upd_by` t_test_b__upd_by , t_test_b.`edit_flag` t_test_b__edit_flag , t_test_b.`tnt_id` t_test_b__tnt_id  FROM t_test_b t_test_b <trim prefix="WHERE" prefixOverrides="AND|OR">
 AND t_test_b.edit_flag=0 and t_test_b.id = #{t_test_a__b_id}
{
  "code": 0,
  "data": {
    "list": [
      {
        "testAVo2": null,
        "testAVo": {
          "crtTm": "2017-11-07 15:17:11",
          "crtBy": null,
          "updTm": "2018-12-18 02:30:11",
          "updBy": "admin",
          "editFlag": 0,
          "tntId": null,
          "id": 1,
          "cid": 1,
          "aid": null,
          "bid": 1
        },
        "testBVo": null,
        "testCVo": null,
        "testDVo": null,
        "testBList": [
          {
            "testBVo": {
              "crtTm": "2017-11-07 15:17:11",
              "crtBy": null,
              "updTm": "2018-12-18 02:30:11",
              "updBy": "admin",
              "editFlag": 0,
              "tntId": null,
              "id": 1,
              "cid": 1,
              "aid": 1
            },
            "testCVo": null
          }
        ],
        "testCList": null
      },
      {
        "testAVo2": null,
        "testAVo": {
          "crtTm": null,
          "crtBy": null,
          "updTm": null,
          "updBy": null,
          "editFlag": 0,
          "tntId": null,
          "id": 2,
          "cid": 1,
          "aid": 1,
          "bid": 1
        },
        "testBVo": null,
        "testCVo": null,
        "testDVo": null,
        "testBList": [
          {
            "testBVo": {
              "crtTm": "2017-11-07 15:17:11",
              "crtBy": null,
              "updTm": "2018-12-18 02:30:11",
              "updBy": "admin",
              "editFlag": 0,
              "tntId": null,
              "id": 1,
              "cid": 1,
              "aid": 1
            },
            "testCVo": null
          }
        ],
        "testCList": null
      }
    ]
  }
}
/**
    * t_test_a 一对多 t_test_b, t_test_a 一对多 t_test_c
    */
   @Link(  print = true, printRm = true, 
           manys = { @OneToMany(leftColumn = "b_id", rightClass = TestBVo.class, ofTypeClass = TestBDto.class, property = "testBList"),
                     @OneToMany(leftColumn = "c_id", rightClass = TestCVo.class, ofTypeClass = TestCDto.class, property = "testCList")})
   List<TestADto> listTestAWTestBWTestC(@Param(Constants.WRAPPER) Wrapper<TestAVo> wrapper);
<script>
SELECT <choose>
<when test="ew != null and ew.sqlSelect != null">
${ew.sqlSelect}
</when>
<otherwise> t_test_a.`id` t_test_a__id , t_test_a.`c_id` t_test_a__c_id , t_test_a.`b_id` t_test_a__b_id , t_test_a.`a_id` t_test_a__a_id , t_test_a.`crt_tm` t_test_a__crt_tm , t_test_a.`crt_by` t_test_a__crt_by , t_test_a.`upd_tm` t_test_a__upd_tm , t_test_a.`upd_by` t_test_a__upd_by , t_test_a.`edit_flag` t_test_a__edit_flag , t_test_a.`tnt_id` t_test_a__tnt_id </otherwise>
</choose> FROM t_test_a t_test_a <trim prefix="WHERE" prefixOverrides="AND|OR">
 AND t_test_a.edit_flag=0
<if test="ew != null">
<if test="ew.id != null">
 AND t_test_a.id = ${ew.id}
</if>
<if test="ew.sqlSegment != null and ew.sqlSegment != '' and ew.nonEmptyOfWhere">
 AND ${ew.sqlSegment}
</if>
<if test="ew.sqlSegment != null and ew.sqlSegment != '' and ew.emptyOfWhere">
 ${ew.sqlSegment}
</if>
</if>
</trim>
</script>
<script>
SELECT  t_test_b.`id` t_test_b__id , t_test_b.`a_id` t_test_b__a_id , t_test_b.`c_id` t_test_b__c_id , t_test_b.`crt_tm` t_test_b__crt_tm , t_test_b.`crt_by` t_test_b__crt_by , t_test_b.`upd_tm` t_test_b__upd_tm , t_test_b.`upd_by` t_test_b__upd_by , t_test_b.`edit_flag` t_test_b__edit_flag , t_test_b.`tnt_id` t_test_b__tnt_id  FROM t_test_b t_test_b <trim prefix="WHERE" prefixOverrides="AND|OR">
 AND t_test_b.edit_flag=0 and t_test_b.id = #{t_test_a__b_id}

</trim>
</script>

<script>
SELECT  t_test_c.`id` t_test_c__id , t_test_c.`a_id` t_test_c__a_id , t_test_c.`b_id` t_test_c__b_id , t_test_c.`c_id` t_test_c__c_id , t_test_c.`crt_tm` t_test_c__crt_tm , t_test_c.`crt_by` t_test_c__crt_by , t_test_c.`upd_tm` t_test_c__upd_tm , t_test_c.`upd_by` t_test_c__upd_by , t_test_c.`edit_flag` t_test_c__edit_flag , t_test_c.`tnt_id` t_test_c__tnt_id  FROM t_test_c t_test_c <trim prefix="WHERE" prefixOverrides="AND|OR">
 AND t_test_c.edit_flag=0 and t_test_c.id = #{t_test_a__c_id}
{
  "code": 0,
  "data": {
    "list": [
      {
        "testAVo2": null,
        "testAVo": {
          "crtTm": "2017-11-07 15:17:11",
          "crtBy": null,
          "updTm": "2018-12-18 02:30:11",
          "updBy": "admin",
          "editFlag": 0,
          "tntId": null,
          "id": 1,
          "cid": 1,
          "aid": null,
          "bid": 1
        },
        "testBVo": null,
        "testCVo": null,
        "testDVo": null,
        "testBList": [
          {
            "testBVo": {
              "crtTm": "2017-11-07 15:17:11",
              "crtBy": null,
              "updTm": "2018-12-18 02:30:11",
              "updBy": "admin",
              "editFlag": 0,
              "tntId": null,
              "id": 1,
              "cid": 1,
              "aid": 1
            },
            "testCVo": null
          }
        ],
        "testCList": [
          {
            "testCVo": {
              "crtTm": "2017-11-07 15:17:11",
              "crtBy": null,
              "updTm": "2018-12-18 02:30:11",
              "updBy": "admin",
              "editFlag": 0,
              "tntId": null,
              "id": 1,
              "cid": 1,
              "aid": 1,
              "bid": 1
            }
          }
        ]
      },
      {
        "testAVo2": null,
        "testAVo": {
          "crtTm": null,
          "crtBy": null,
          "updTm": null,
          "updBy": null,
          "editFlag": 0,
          "tntId": null,
          "id": 2,
          "cid": 1,
          "aid": 1,
          "bid": 1
        },
        "testBVo": null,
        "testCVo": null,
        "testDVo": null,
        "testBList": [
          {
            "testBVo": {
              "crtTm": "2017-11-07 15:17:11",
              "crtBy": null,
              "updTm": "2018-12-18 02:30:11",
              "updBy": "admin",
              "editFlag": 0,
              "tntId": null,
              "id": 1,
              "cid": 1,
              "aid": 1
            },
            "testCVo": null
          }
        ],
        "testCList": [
          {
            "testCVo": {
              "crtTm": "2017-11-07 15:17:11",
              "crtBy": null,
              "updTm": "2018-12-18 02:30:11",
              "updBy": "admin",
              "editFlag": 0,
              "tntId": null,
              "id": 1,
              "cid": 1,
              "aid": 1,
              "bid": 1
            }
          }
        ]
      }
    ]
  }
}
/**
     * t_test_a 一对一  t_test_b, t_test_a 一对多 t_test_b
     */
    @Link(  print = true, printRm = true,
            ones = { @OneToOne(leftColumn = "b_id", rightClass = TestBVo.class)},
            manys = { @OneToMany(leftClass = TestAVo.class, leftColumn = "b_id", rightClass = TestBVo.class, ofTypeClass = TestBDto.class, property = "testBList") })
    List<TestADto> listTestAATestBWTestB(@Param(Constants.WRAPPER) Wrapper<TestAVo> wrapper);
<script>
SELECT <choose>
<when test="ew != null and ew.sqlSelect != null">
${ew.sqlSelect}
</when>
<otherwise> t_test_a.`id` t_test_a__id , t_test_a.`c_id` t_test_a__c_id , t_test_a.`b_id` t_test_a__b_id , t_test_a.`a_id` t_test_a__a_id , t_test_a.`crt_tm` t_test_a__crt_tm , t_test_a.`crt_by` t_test_a__crt_by , t_test_a.`upd_tm` t_test_a__upd_tm , t_test_a.`upd_by` t_test_a__upd_by , t_test_a.`edit_flag` t_test_a__edit_flag , t_test_a.`tnt_id` t_test_a__tnt_id , t_test_b.`id` t_test_b__id , t_test_b.`a_id` t_test_b__a_id , t_test_b.`c_id` t_test_b__c_id , t_test_b.`crt_tm` t_test_b__crt_tm , t_test_b.`crt_by` t_test_b__crt_by , t_test_b.`upd_tm` t_test_b__upd_tm , t_test_b.`upd_by` t_test_b__upd_by , t_test_b.`edit_flag` t_test_b__edit_flag , t_test_b.`tnt_id` t_test_b__tnt_id </otherwise>
</choose> FROM t_test_a t_test_a INNER JOIN t_test_b t_test_b <trim prefix="WHERE" prefixOverrides="AND|OR">
 AND t_test_a.edit_flag=0 AND t_test_b.edit_flag=0 and t_test_a.b_id=t_test_b.id
<if test="ew != null">
<if test="ew.id != null">
 AND t_test_a.id = ${ew.id}
</if>
<if test="ew.sqlSegment != null and ew.sqlSegment != '' and ew.nonEmptyOfWhere">
 AND ${ew.sqlSegment}
</if>
<if test="ew.sqlSegment != null and ew.sqlSegment != '' and ew.emptyOfWhere">
 ${ew.sqlSegment}
</if>
</if>
</trim>
</script>

<script>
SELECT  t_test_b.`id` t_test_b__id , t_test_b.`a_id` t_test_b__a_id , t_test_b.`c_id` t_test_b__c_id , t_test_b.`crt_tm` t_test_b__crt_tm , t_test_b.`crt_by` t_test_b__crt_by , t_test_b.`upd_tm` t_test_b__upd_tm , t_test_b.`upd_by` t_test_b__upd_by , t_test_b.`edit_flag` t_test_b__edit_flag , t_test_b.`tnt_id` t_test_b__tnt_id  FROM t_test_b t_test_b <trim prefix="WHERE" prefixOverrides="AND|OR">
 AND t_test_b.edit_flag=0 and t_test_b.id = #{t_test_a__b_id}

</trim>
</script>
/**
     * t_test_a 一对一  t_test_b, t_test_a 一对多 t_test_b, 多表中 t_test_b 一对一 t_test_c
     */
    @Link(  print = true, printRm = true,
            ones = { @OneToOne(leftColumn = "b_id", rightClass = TestBVo.class)},
            manys = { @OneToMany(leftClass = TestAVo.class, leftColumn = "b_id", rightClass = TestBVo.class, ofTypeClass = TestBDto.class, property = "testBList", 
            ones = { @OneToOne(leftColumn = "c_id", rightClass = TestCVo.class)} )})
    List<TestADto> listTestAATestBWTestBATestC(@Param(Constants.WRAPPER) Wrapper<TestAVo> wrapper);
<script>
SELECT <choose>
<when test="ew != null and ew.sqlSelect != null">
${ew.sqlSelect}
</when>
<otherwise> t_test_a.`id` t_test_a__id , t_test_a.`c_id` t_test_a__c_id , t_test_a.`b_id` t_test_a__b_id , t_test_a.`a_id` t_test_a__a_id , t_test_a.`crt_tm` t_test_a__crt_tm , t_test_a.`crt_by` t_test_a__crt_by , t_test_a.`upd_tm` t_test_a__upd_tm , t_test_a.`upd_by` t_test_a__upd_by , t_test_a.`edit_flag` t_test_a__edit_flag , t_test_a.`tnt_id` t_test_a__tnt_id , t_test_b.`id` t_test_b__id , t_test_b.`a_id` t_test_b__a_id , t_test_b.`c_id` t_test_b__c_id , t_test_b.`crt_tm` t_test_b__crt_tm , t_test_b.`crt_by` t_test_b__crt_by , t_test_b.`upd_tm` t_test_b__upd_tm , t_test_b.`upd_by` t_test_b__upd_by , t_test_b.`edit_flag` t_test_b__edit_flag , t_test_b.`tnt_id` t_test_b__tnt_id </otherwise>
</choose> FROM t_test_a t_test_a INNER JOIN t_test_b t_test_b <trim prefix="WHERE" prefixOverrides="AND|OR">
 AND t_test_a.edit_flag=0 AND t_test_b.edit_flag=0 and t_test_a.b_id=t_test_b.id
<if test="ew != null">
<if test="ew.id != null">
 AND t_test_a.id = ${ew.id}
</if>
<if test="ew.sqlSegment != null and ew.sqlSegment != '' and ew.nonEmptyOfWhere">
 AND ${ew.sqlSegment}
</if>
<if test="ew.sqlSegment != null and ew.sqlSegment != '' and ew.emptyOfWhere">
 ${ew.sqlSegment}
</if>
</if>
</trim>
</script>

<script>
SELECT  t_test_b.`id` t_test_b__id , t_test_b.`a_id` t_test_b__a_id , t_test_b.`c_id` t_test_b__c_id , t_test_b.`crt_tm` t_test_b__crt_tm , t_test_b.`crt_by` t_test_b__crt_by , t_test_b.`upd_tm` t_test_b__upd_tm , t_test_b.`upd_by` t_test_b__upd_by , t_test_b.`edit_flag` t_test_b__edit_flag , t_test_b.`tnt_id` t_test_b__tnt_id , t_test_c.`id` t_test_c__id , t_test_c.`a_id` t_test_c__a_id , t_test_c.`b_id` t_test_c__b_id , t_test_c.`c_id` t_test_c__c_id , t_test_c.`crt_tm` t_test_c__crt_tm , t_test_c.`crt_by` t_test_c__crt_by , t_test_c.`upd_tm` t_test_c__upd_tm , t_test_c.`upd_by` t_test_c__upd_by , t_test_c.`edit_flag` t_test_c__edit_flag , t_test_c.`tnt_id` t_test_c__tnt_id  FROM t_test_b t_test_b INNER JOIN t_test_c t_test_c <trim prefix="WHERE" prefixOverrides="AND|OR">
 AND t_test_b.edit_flag=0 and t_test_b.id = #{t_test_a__b_id}
 AND t_test_c.edit_flag=0 and t_test_b.c_id=t_test_c.id
</trim>
</script>
{
  "code": 0,
  "data": {
    "list": [
      {
        "testAVo2": null,
        "testAVo": {
          "crtTm": "2017-11-07 15:17:11",
          "crtBy": null,
          "updTm": "2018-12-18 02:30:11",
          "updBy": "admin",
          "editFlag": 0,
          "tntId": null,
          "id": 1,
          "cid": 1,
          "aid": null,
          "bid": 1
        },
        "testBVo": {
          "crtTm": "2017-11-07 15:17:11",
          "crtBy": null,
          "updTm": "2018-12-18 02:30:11",
          "updBy": "admin",
          "editFlag": 0,
          "tntId": null,
          "id": 1,
          "cid": 1,
          "aid": 1
        },
        "testCVo": null,
        "testDVo": null,
        "testBList": [
          {
            "testBVo": {
              "crtTm": "2017-11-07 15:17:11",
              "crtBy": null,
              "updTm": "2018-12-18 02:30:11",
              "updBy": "admin",
              "editFlag": 0,
              "tntId": null,
              "id": 1,
              "cid": 1,
              "aid": 1
            },
            "testCVo": {
              "crtTm": "2017-11-07 15:17:11",
              "crtBy": null,
              "updTm": "2018-12-18 02:30:11",
              "updBy": "admin",
              "editFlag": 0,
              "tntId": null,
              "id": 1,
              "cid": 1,
              "aid": 1,
              "bid": 1
            }
          }
        ],
        "testCList": null
      },
      {
        "testAVo2": null,
        "testAVo": {
          "crtTm": null,
          "crtBy": null,
          "updTm": null,
          "updBy": null,
          "editFlag": 0,
          "tntId": null,
          "id": 2,
          "cid": 1,
          "aid": 1,
          "bid": 1
        },
        "testBVo": {
          "crtTm": "2017-11-07 15:17:11",
          "crtBy": null,
          "updTm": "2018-12-18 02:30:11",
          "updBy": "admin",
          "editFlag": 0,
          "tntId": null,
          "id": 1,
          "cid": 1,
          "aid": 1
        },
        "testCVo": null,
        "testDVo": null,
        "testBList": [
          {
            "testBVo": {
              "crtTm": "2017-11-07 15:17:11",
              "crtBy": null,
              "updTm": "2018-12-18 02:30:11",
              "updBy": "admin",
              "editFlag": 0,
              "tntId": null,
              "id": 1,
              "cid": 1,
              "aid": 1
            },
            "testCVo": {
              "crtTm": "2017-11-07 15:17:11",
              "crtBy": null,
              "updTm": "2018-12-18 02:30:11",
              "updBy": "admin",
              "editFlag": 0,
              "tntId": null,
              "id": 1,
              "cid": 1,
              "aid": 1,
              "bid": 1
            }
          }
        ],
        "testCList": null
      }
    ]
  }
}
/**
     * t_test_a 与   t_test_b 一对一分页连表查询
     */
    @Link(  print = true, printRm = true,
            ones = { @OneToOne(rightClass = TestBVo.class, rightColumn = "a_id") })
    IPage<TestADto> pageTestAATestB(IPage<TestADto> page, @Param(Constants.WRAPPER) Wrapper<TestAVo> wrapper);
<script>
SELECT <choose>
<when test="ew != null and ew.sqlSelect != null">
${ew.sqlSelect}
</when>
<otherwise> t_test_a.`id` t_test_a__id , t_test_a.`c_id` t_test_a__c_id , t_test_a.`b_id` t_test_a__b_id , t_test_a.`a_id` t_test_a__a_id , t_test_a.`crt_tm` t_test_a__crt_tm , t_test_a.`crt_by` t_test_a__crt_by , t_test_a.`upd_tm` t_test_a__upd_tm , t_test_a.`upd_by` t_test_a__upd_by , t_test_a.`edit_flag` t_test_a__edit_flag , t_test_a.`tnt_id` t_test_a__tnt_id , t_test_b.`id` t_test_b__id , t_test_b.`a_id` t_test_b__a_id , t_test_b.`c_id` t_test_b__c_id , t_test_b.`crt_tm` t_test_b__crt_tm , t_test_b.`crt_by` t_test_b__crt_by , t_test_b.`upd_tm` t_test_b__upd_tm , t_test_b.`upd_by` t_test_b__upd_by , t_test_b.`edit_flag` t_test_b__edit_flag , t_test_b.`tnt_id` t_test_b__tnt_id </otherwise>
</choose> FROM t_test_a t_test_a INNER JOIN t_test_b t_test_b <trim prefix="WHERE" prefixOverrides="AND|OR">
 AND t_test_a.edit_flag=0 AND t_test_b.edit_flag=0 and t_test_a.id=t_test_b.a_id
<if test="ew != null">
<if test="ew.id != null">
 AND t_test_a.id = ${ew.id}
</if>
<if test="ew.sqlSegment != null and ew.sqlSegment != '' and ew.nonEmptyOfWhere">
 AND ${ew.sqlSegment}
</if>
<if test="ew.sqlSegment != null and ew.sqlSegment != '' and ew.emptyOfWhere">
 ${ew.sqlSegment}
</if>
</if>
</trim>
</script>
{
  "code": 0,
  "data": {
    "list": [
      {
        "testAVo2": null,
        "testAVo": {
          "crtTm": "2017-11-07 15:17:11",
          "crtBy": null,
          "updTm": "2018-12-18 02:30:11",
          "updBy": "admin",
          "editFlag": 0,
          "tntId": null,
          "id": 1,
          "cid": 1,
          "aid": null,
          "bid": 1
        },
        "testBVo": {
          "crtTm": "2017-11-07 15:17:11",
          "crtBy": null,
          "updTm": "2018-12-18 02:30:11",
          "updBy": "admin",
          "editFlag": 0,
          "tntId": null,
          "id": 1,
          "cid": 1,
          "aid": 1
        },
        "testCVo": null,
        "testDVo": null,
        "testBList": null,
        "testCList": null
      }
    ]
  },
  "page": {
    "total": 1,
    "pageSize": 10,
    "pageNum": 1
  }
}
/**
     * t_test_a 与   t_test_b 连表行数查询
     */
    @Link(  print = true, printRm = true,
            ones = { @OneToOne(rightClass = TestBVo.class, rightColumn = "a_id") })
    Integer countTestAATestB(@Param(Constants.WRAPPER) Wrapper<TestAVo> wrapper);
<script>
SELECT COUNT(1) FROM t_test_a t_test_a INNER JOIN t_test_b t_test_b <trim prefix="WHERE" prefixOverrides="AND|OR">
 AND t_test_a.edit_flag=0 AND t_test_b.edit_flag=0 and t_test_a.id=t_test_b.a_id
<if test="ew != null">
<if test="ew.sqlSegment != null and ew.sqlSegment != '' and ew.nonEmptyOfWhere">
 AND ${ew.sqlSegment}
</if>
<if test="ew.sqlSegment != null and ew.sqlSegment != '' and ew.emptyOfWhere">
 ${ew.sqlSegment}
</if>
</if>
</trim>
</script>
{
  "code": 0,
  "data": 1
}

  • 3
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值