房产交易网站建设策划案店铺推广软文300字
1.今天用mybatis实现批量更新,一直报错,说我的sql语句不对,然后我还到mysql下面试了,明明没问题,但就是过不去,原来问题在这。
在连接数据库的url中要加入?allowMultiQueries=true这段,而且要放在第一行
dao层:
mapper层:
解释一下,我的collection=“list”,为什么写list,因为传入的是一个list集合,这里必须写list,
如果传入一个数组比如Integer[],那么就要写collection="array"
<!-- 如果不是第一次参加考试,就更新学生的答案 --><update id="updateStudentAnswer" parameterType="java.util.List"><if test="list!=null"><foreach collection="list" item="studentAnswer" index= "index" open="" close="" separator =";">update studentanswerinfo<set>SAnswer=#{studentAnswer.SAnswer},Getpoint=#{studentAnswer.Getpoint},other=#{studentAnswer.other}</set><where>questionID=#{studentAnswer.questionID}</where></foreach></if></update>
一个疑问: 最后返回修改成功的数据条数为1(其实修改了多条数据)