mybatis

sql优化

复杂resultmap

<resultMap id="BaseAllResultMap2" type="com.xxxx.test1" >
    <id column="oId" property="id" jdbcType="BIGINT" />
    <collection property="sub1" columnPrefix="rfo_" ofType="com.xxxx.sub1">
        <id column="id" property="id" jdbcType="BIGINT" />
        <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
        <collection property="sub1_1" columnPrefix="d_" ofType="com.xxxx.sub1_1" >
            <id column="id" property="id" jdbcType="BIGINT" />
        </collection>
        <collection property="sub1_2" columnPrefix="t_" ofType="com.xxxx.sub1_2" >
            <id column="id" property="id" jdbcType="BIGINT" />
            <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
        </collection>
    </collection>
    <collection property="sub2" columnPrefix="ho_" ofType="com.xxxx.sub2" >
        <id column="id" property="id" jdbcType="BIGINT" />
        <collection property="sub2_1" columnPrefix="r_" ofType="com.xxxx.sub2_1" >
            <id column="id" property="id" jdbcType="BIGINT" />
        </collection>
    </collection>
  </resultMap>
SELECT
 o.id AS oId,
rfo_.id as rfo_id,
rfo_.create_time as rfo_create_time,
rfo_d_.id as rfo_d_id,
rfo_t_.id as rfo_t_id,
rfo_t_.create_time as rfo_t_create_time,
ho_.id as ho_id,
ho_r_.id as ho_r_id,
      FROM
      resource_main_order o
      LEFT JOIN sub1 rfo_ ON o.id = rfo_.id 
      LEFT JOIN sub1_1 rfo_d_ ON rfo_.id = rfo_d_.id 
      LEFT JOIN sub1_2 rfo_t_ ON rfo_.id = rfo_t_.id 
      LEFT JOIN sub2 ho_ ON o.id = ho_.id 
      LEFT JOIN sub2_1 ho_r_ ON ho_.id = ho_r_.id 
已标记关键词 清除标记
相关推荐
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页