这是dao
@DAOAction(action = DAOActionType.INSERT)
public int batchInsertGroupShoup(@DAOParam(value = "list", type = DAOParamType.NORMAL) List<GroupShop> list); <insert id="batchInsertGroupShoup" parameterClass="map">
INSERT INTO DPEvent.ACT_GroupShop(<include refid="allColumns"/>)
VALUES
<iterate property="list" conjunction=",">
(#list[].shopTitle#,
#list[].shopIntroduce#,
#list[].shopPic#,
#list[].groupType#,
#list[].cityID#,
#list[].foretasteFund#,
#list[].nowPrice#,
#list[].oldPrice#,
#list[].saledNum#,
#list[].num#,
#list[].groupNum#,
#list[].activityID#,
#list[].status#,
#list[].userId#,
NOW(),
NOW()
)
</iterate >
<selectKey resultClass="int" keyProperty="id">
SELECT @@IDENTITY AS id
</selectKey>
</insert>
注意的地方 values不能有;结束符 不然 当数据只有一条的时候 是正常的 到了第二条数据的时候就会报错了
conjunction 这个属性是 当你执行循环结束的时候追加的 字符串
本文详细介绍了如何使用SQL的批量插入方法`batchInsertGroupShoup`来高效地将一组`GroupShop`对象插入到`DPEvent.ACT_GroupShop`表中,包括参数配置、SQL语法细节以及常见错误处理。
718





