Java之MyBatis 批量删除数据,两种方式(注解,XML)

x33g5p2x  于2022-02-18 转载在 Java  
字(0.6k)|赞(0)|评价(0)|浏览(361)

1、MyBatis之 XML 批量删除数据

  1. public int deleteSysStudentStuIds(Long[] stuIds);
  1. <delete id="deleteSysStudentStuIds" parameterType="String">
  2. delete from sys_student where stu_id in
  3. <foreach item="stuId" collection="array" open="(" separator="," close=")">
  4. #{stuId}
  5. </foreach>
  6. </delete>

2、MyBatis之 注解 批量删除数据

  1. @Delete("<script>
  2. delete from sys_student where stu_id in
  3. <foreach collection='array' item='stuId' open='(' separator=',' close=')'>#{stuId}</foreach>
  4. </script>")
  5. void delete(Long[] stuIds);

相关文章

最新文章

更多