先贴代码
<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前或后执行
本文详细解析了 MyBatis 中 SelectKey 标签的使用方法及其与 insert 操作的配合流程,介绍了 keyProperty 和 order 属性的作用。
948

被折叠的 条评论
为什么被折叠?



