先贴代码
<insert id="addPageContent" parameterType="com.sitech.dbs.busi.ProdPortalVisual.model.PortalPageContent">
<selectKey keyProperty="contentId" resultType="int"
order="BEFORE">
select TB_CMS_PAGE_CONTENT_SEQ.NEXTVAL as contentId from DUAL
</selectKey>
insert into TB_CMS_PAGE_CONTENT(content_id,catalog_id,module_content,adv_content,menu_content)
values(#{contentId},#{catalogId},#{moduleContent},#{advContent},#{menuContent})
</insert>
重点是selectkey标签,其中keyProperty属性指定selectKey返回的值赋予哪个属性,若parameterType是map,则会在map中插入该属性,若为对象,则修改对象该属性值,order属性有before和after,指定改selectKey是在insert前或后执行