Mapper.xml

<resultMap id="resuleMap" type="com.com.entity.xxx">

  <id property="id" column="id"></id>

  <result property="xxx" column="xxx"></result >

  <result property="xxx" column="xxx"></result >

  <association property="entity" column="entity_id" select="selectentityById"> </association > //@TableField(exist = false) 

  <collection property="entityList" column="id" javaType="ArrayList" select="selectentityById"> </collection>

</resultMap>

<select id="selectentityById" parameterType="String" resultType="com.com.entity.xxx" >

  select * from xxx where xxx_id = #{xxxid}

</select>

<select id="selectentityById" parameterType="String" resultType="com.com.entity.xxx" >

  select * from xxx where id = #{id}

</select>

——————————————————————————————————————————————————————

<resultMap id="resuleMap" type="com.com.entity.xxx">

  <id property="id" column="id"></id>

  <result property="xxx" column="xxx"></result >

  <result property="xxx" column="xxx"></result >

  <collection property="entityList" ofType="com.com.entity.xxx" > //@TableField(exist = false)

    <id property="xxx_id" column="xxx_id"></id>

    <result property="xxx" column="xxx"></result >

    <result property="xxx" column="xxx"></result >

  </collection>

</resultMap>

 

<select id="selectentityById" parameterType="String" resultType="resuleMap" >

  select 

    ca.*,

    ct.*,

    ct.id as xxx_id

  from

    xxx ca

    left join xxx ct on ca.id = ct.xxxid

  where

    id = #{id}

</select>

 ————————————————————————————————————————————

<resultMap id="resuleMap" type="com.com.entity.xxx">

  <id property="id" column="id"></id>

  <result property="xxx" column="xxx"></result >

  <result property="xxx" column="xxx"></result >

  <association property="entity" column="entity_id" select="selectentityById"> </association > //@TableField(exist = false) 

  <collection property="entityList" column="id" javaType="ArrayList" select="selectentityById"> </collection>

  <collection property="entityList" ofType="com.com.entity.xxx" column="id" javaType="ArrayList" select="selectentityById" > //@TableField(exist = false)

    <result property="xxx" column="xxx"></result >

    <result property="xxx" column="xxx"></result >

  </collection>

</resultMap>

<select id="selectentityById" parameterType="String" resultType="com.com.entity.xxx" >

  select 

    xxx.xx as xx,

    xxx.xx as xx,

  from

     xxx

    left join xxx on xxx

  where xxx_id = #{xxxid}

</select>

<select id="selectentityById" parameterType="String" resultType="com.com.entity.xxx" >

  select * from xxx where xxx_id = #{xxxid}

</select>

<select id="selectentityById" parameterType="String" resultType="com.com.entity.xxx" >

  select * from xxx where id = #{id}

</select>

————————————————————————————————————————————

<select id="selectentityById"  resultType="resuleMap" >

  select  *

  from xxx

  <where>

    xxx in 

    <foreach collection="xxxList" item="xxx" open="(" close=")" separator=",">

      #{xxxId}

    </foreach>

    and xxx.xx = xx

  </where>

</select>

----------------------------------------------------

<collection property="entityList" column="{id=id,xxx=xx}" javaType="ArrayList" select="selectentityById"> </collection>

-----------------------------------------------

if标签的深度使用:   https://blog.csdn.net/DATANGguanjunhou/article/details/106426229

 

posted @ 2023-12-15 15:38  应景的BGM  阅读(43)  评论(0)    收藏  举报