<resultMap id="columnResult" type="Column">
<id property="id" column="id"/>
<collection property="contents" javaType="ArrayList" column="wid" ofType="Content"
select="selectContentForColumn"></collection>
</resultMap>
<select id="getColumn" parameterType="int" resultMap="columnResult">
SELECT ID,NAME FROM WebSite_Column WHERE STATE = '1' AND ID=#{id}
</select>
<select id="selectContentForColumn" parameterType="string" resultType="Content">
SELECT ID,WID,SUBJECT FROM WebSite_Content WHERE WID=#{id}
ORDER BY CREATE_TIME DESC
</select>看了好多文章都是传一个参数进来,两个句子用。说一下关系Column是一个类,Cotent是一个类,两都是一对多关系。我现在要进行联合查询。
我现在想做的是不传参数,查询column集合,在把每个column下的cotent查询出来放到column的List<Content> contents中去。我是想联合查询的方式 。
<id property="id" column="id"/>
<collection property="contents" javaType="ArrayList" column="wid" ofType="Content"
select="selectContentForColumn"></collection>
</resultMap>
<select id="getColumn" parameterType="int" resultMap="columnResult">
SELECT ID,NAME FROM WebSite_Column WHERE STATE = '1' AND ID=#{id}
</select>
<select id="selectContentForColumn" parameterType="string" resultType="Content">
SELECT ID,WID,SUBJECT FROM WebSite_Content WHERE WID=#{id}
ORDER BY CREATE_TIME DESC
</select>看了好多文章都是传一个参数进来,两个句子用。说一下关系Column是一个类,Cotent是一个类,两都是一对多关系。我现在要进行联合查询。
我现在想做的是不传参数,查询column集合,在把每个column下的cotent查询出来放到column的List<Content> contents中去。我是想联合查询的方式 。
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货