</pre><pre name="code" class="java">
当前对象的xml设置中
返回类型
<resultMap id="releaseUnitMap" type="com.afocus.fa.release.model.ReleaseUnit"><result property="id" column="ID"></result>
<result property="name" column="NAME"></result>
<result property="platformId" column="PLATFORM_ID"></result>
<result property="categoryId" column="CATEGORY_ID"></result>
<result property="brandId" column="BRAND_ID"></result>
<result property="goodsName" column="GOODS_NAME"></result>
<result property="originalPrice" column="ORIGINAL_PRICE"></result>
<result property="presentPrice" column="PRESENT_PRICE"></result>
<result property="type" column="TYPE"></result>
<result property="status" column="STATUS"></result>
<result property="createTime" column="CREATE_TIME"></result>
<result property="updateTime" column="UPDATE_TIME"></result>
<result property="creatorId" column="CREATOR_ID"></result>
<result property="creatorName" column="CREATOR_NAME"></result>
<result property="categoryName" column="categoryName"></result>
<result property="brandName" column="brandName"></result>
<result property="platformName" column="platformName"></result>
<!-- 其他定义字段 -->
<result property="searchStartTime" column=""></result>
<result property="searchEndTime" column=""></result>
<!-- 投放地域数据 通用 一对一-->
<association property=" releaseArea"
javaType="com.afocus.fa.release.model.ReleaseArea"
resultMap="com.afocus.fa.release.dao.ReleaseAreaDao. globalReleaseArea"/>
<!-- 天猫直通车投放方式数据 一对多 -->
<collection property=" tmztcReleaseWays"
ofType="com.afocus.fa.release.model.ReleaseTmztcWay"
resultMap="com.afocus.fa.release.dao.ReleaseTmztcWayDao.globalReleaseTmztcWay"/>
<!-- 天猫直通车投放时间数据 -->
<collection property=" tmztcReleaseTimes"
ofType="com.afocus.fa.release.model.ReleaseTmztcTime"
resultMap="com.afocus.fa.release.dao.ReleaseTmztcTimeDao.globalReleaseTmztcTime"/>
</resultMap>
查询语句
<select id="loadTmztcInformation" resultMap="releaseUnitMap">
SELECT <include refid="field"/>,
MC.NAME categoryName,MB.NAME brandName,MP.NAME platformName,
<include refid="com.afocus.fa.release.dao.ReleaseTmztcWayDao.globalField"/>,
<include refid="com.afocus.fa.release.dao.ReleaseTmztcTimeDao.globalField"/>,
<include refid="com.afocus.fa.release.dao.ReleaseAreaDao.globalField"/>
FROM FA_RELEASE_UNIT RU
LEFT JOIN (SELECT * FROM FA_MANAGE_CATEGORY CA WHERE CA.STATUS != -1) MC
ON RU.CATEGORY_ID = MC.ID
LEFT JOIN (SELECT * FROM FA_MANAGE_BRAND BR WHERE BR.STATUS !=1) MB
ON RU.BRAND_ID = MB.ID
LEFT JOIN (SELECT * FROM FA_MANAGE_PLATFORM PL WHERE PL.STATUS!=-1) MP
ON MP.ID =RU.PLATFORM_ID
LEFT JOIN (SELECT * FROM FA_RELEASE_TMZTC_WAY WA WHERE WA.STATUS !=-1) RTW
ON RTW.UNIT_ID=RU.ID
LEFT JOIN (SELECT * FROM FA_RELEASE_TMZTC_TIME T WHERE T.STATUS !=-1) RTT
ON RTT.UNIT_ID=RU.ID
LEFT JOIN (SELECT * FROM FA_RELEASE_AREA A WHERE A.STATUS !=-1) RA
ON RA.UNIT_ID=RU.ID
<include refid="dynamicWhere" />
</select>
当前对象的model中
private ReleaseArea releaseArea;
private List<ReleaseTmztcWay> tmztcReleaseWays;
private List<ReleaseTmztcTime> tmztcReleaseTimes;
投放地域的xml 注意对应样色相同的相互对应
<sql id="globalField">
RA.ID RA_ID, RA.UNIT_ID RA_UNIT_ID, RA.PROVINCE, RA.TYPE RA_TYPE, RA.STATUS RA_STATUS,
RA.CREATE_TIME RA_CREATE_TIME, RA.UPDATE_TIME RA_UPDATE_TIME, RA.CREATOR_ID RA_CREATOR_ID, RA.CREATOR_NAME RA_CREATOR_NAME
</sql>
<resultMap id="globalReleaseArea" type="com.afocus.fa.release.model.ReleaseArea">
<result property="id" column="RA_ID"></result>
<result property="unitId" column="RA_UNIT_ID"></result>
<result property="province" column="PROVINCE"></result>
<result property="type" column="RA_TYPE"></result>
<result property="status" column="RA_STATUS"></result>
<result property="createTime" column="RA_CREATE_TIME"></result>
<result property="updateTime" column="RA_UPDATE_TIME"></result>
<result property="creatorId" column="RA_CREATOR_ID"></result>
<result property="creatorName" column="RA_CREATOR_NAME"></result>
</resultMap>
其他的xml也就和投放地域的设置相同