插入查询获得当前的自增主键ID值
<insert id="insert" useGeneratedKeys="true" keyProperty="userId">
insert into user(userName,password,regTime)
values(#{userName},#{password},#{regTime})
</insert>
批量查询in根据顺序返回对象
<select id="findByCommentParentId" parameterType="java.util.List" resultType="com.bysj.work.nsfz.model.Comment">
SELECT * FROM nsfz_comment WHERE commentId in
<foreach collection="list" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
order by
field(
commentId,
<foreach collection="list" index="index" item="item" separator="," >
#{item}
</foreach>
)
</select>