mybatis

插入查询获得当前的自增主键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>

 

posted @ 2019-03-16 17:02  change丶fl  阅读(102)  评论(0编辑  收藏  举报