50,528
社区成员
发帖
与我相关
我的任务
分享
public class Disclosure
{
/**
* DISCLOSURE_ID:爆料信息id
*/
private long id;
/**
* 附件列表
*/
private List<Attachment> attachments;
}
<resultMap id="disclosureMap"
type="xxxx.Disclosure">
<id property="id" column="DISCLOSURE_ID" />
<collection property="attachments" column="DISCLOSURE_ID"
ofType="xxx.Attachment"
select="xxx.DisAttachmentMapper.getAttachmentsByDisclosureId">
</collection>
</resultMap>
上面是对应disclosure类的resultMap
DisAttachmentMapper.getAttachmentsByDisclosureId
对应的mapper
<resultMap id="attachmentMap" type="xxx.Attachment">
<result property="attachmentId" column="DISCL_ATT_ID" />
<result property="attachmentUrl" column="ATTACHMENT_URL" />
</resultMap>
<select id="getAttachmentsByDisclosureId" parameterType="long" resultMap="attachmentMap">
select DISCL_ATT_ID,ATTACHMENT_URL from DISCLOSURE_ATTACHMENT where DISCLOSURE_ID =#{disclosureId}
</select>
大概这样吧