下面是本人使用,红色为需要注意的地方
<resultMap id="ResultStatisticsPrincipals" type="cn.xxx.clue.pojo.StatisticsPrincipals">
<result column="uploadCount" property="uploadCount" jdbcType="INTEGER" />
<result column="market_cathedra_code" property="marketCathedraCode" jdbcType="VARCHAR" />
<result column="principals" property="principal" jdbcType="VARCHAR" />
<result column="form_id" property="formId" jdbcType="VARCHAR" />
<result column="dataWillDepartmentBM" property="dataWillDepartmentBM" jdbcType="VARCHAR" />
<result column="dataWillDepartmentYLB" property="dataWillDepartmentYLB" jdbcType="VARCHAR" />
<collection property="listClueDatas" select="selectClueDataBMarketCathedraCode" column="{marketCathedraCode=market_cathedra_code,select_channel=channel}"
javaType="java.util.ArrayList"
ofType="cn.xdf.clue.pojo.ClueDataWithBLOBs" extend="com.xxx.RoleBean">
</collection>
上段代码column="{marketCathedraCode=market_cathedra_code,select_channel=channel}"
中的marketCathedraCode、select_channel 都是随便起的名字,后面market_cathedra_code、channel 对应的是外层查询的字段(column)名
<select id="selectClueDataBMarketCathedraCode" resultMap="ResultMapWithBLOBs" parameterType="java.util.Map" >
select
<include refid="Base_Column_List" />,
<include refid="Blob_Column_List" />
from clue_data
where market_cathedra_code = #{marketCathedraCode,jdbcType=VARCHAR}
<if test="channel != null and channel != ''">
and cd.channel = #{select_channel,jdbcType=VARCHAR}
</if>
AND principals is not null and principals <![CDATA[ <> ]]> '' and principals <![CDATA[ <> ]]> '0'
and data_available = '1'
</select>
注:上面parameterType="java.util.Map"一定要用map,这个地方是根据上面的key去取传入的参数