1、插入语句返回成功ID
<selectKey keyProperty="id" resultType="int" order="AFTER">
</selectKey> -->
<!-- insert into wm_index_billing(title,publish_time,image_url) values(${title} , ${publishTime} , ${imageUrl})
2、循环遍历
<select id="getServiceTypeList" parameterType="com....entity.PreCreatebillrelationEntity" resultMap="preServiceTypeEntity">
select * from v_pre_servicetype where ID in
<foreach item="item" collection="list" index="index" open="(" separator="," close=")">
#{item.serviceId}
</foreach>
</select>
serviceId为PreCreatebillrelationEntity中的属性
3、在插入一条数据后返回该条数据的主键ID
<insert id="saveActivity" parameterType="com.....entity.mobile.Activity" useGeneratedKeys="true" keyProperty="id">
INSERT INTO
TSM_ACTIVITY(NAME,SUMMARY,BEGIN_DATE,END_DATE,THUMBNAIL_URL,DISTINCT_URL,DEPLOY_DATE,TOP_DATE,STATUS)
VALUES(#{name},#{summary},#{beginDate},#{endDate},#{thumbnailUrl},#{distinctUrl},#{deployDate},#{topDate},#{status})
</insert>
在insert标签中添加属性useGeneratedKeys="true" keyProperty="id"
keyProperty的值为实体类中的主键属性