实体: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>