ibatis多表连接的写法,返回一个实体

实体:ClassA

      private String instanceid;
      private String regionid;
      //拼接用的
      private String size;
      private String type;
      private String status;


数据库:TableA

      private String instanceid;
      private String regionid;


ibatis.xml配置

<resultMap id="result" class="AliEcsSnapshot">
        <result property="id" column="ID"/>
        <result property="diskid" column="DISKID"/>
        <result property="ecs_instance_id" column="ECS_INSTANCE_ID"/>
        <result property="snapshotname" column="SNAPSHOTNAME"/>
        <result property="clienttoken" column="CLIENTTOKEN"/>
        <result property="creator_id" column="CREATOR_ID"/>
        <result property="creator_name" column="CREATOR_NAME"/>
        <result property="creator_dep" column="CREATOR_DEP"/>
        <result property="creator_depname" column="CREATOR_DEPNAME"/>
        <result property="description" column="DESCRIPTION"/>
        <result property="create_time" column="CREATE_TIME"/>
        <result property="snapshotid" column="SNAPSHOTID"/>
        <result property="instanceid" column="instanceid"/>
        <result property="regionid" column="regionid"/>
    </resultMap>    
    
    <resultMap id="listresult" extends="result" class="AliEcsSnapshot" >
        <result property="size" column="size"/>
        <result property="type" column="type"/>
        <result property="status" column="status"/>

    </resultMap>


SQL写法:

<select id="findSnapshotByDyConditon4Map" parameterClass="AliEcsSnapshot" resultMap="listresult">
        <include refid="pageStart"/>
        select s.*,d.type,d.size,d.status from ali_ecs_snapshot s,ali_disk d where s.ECS_INSTANCE_ID=#ecs_instance_id# and s.diskid=d.diskid
        <include refid="pageEnd"/>
    </select>



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值