今天遇到这个问题:Column count doesn’t match value count at row 1
很明显说的是列不匹配。
示例是 insert into user(colum1,colum2,colum3)
但是values是(字段1,字段2)这种信息。列名不匹配
我这次虽然报这个错误。但是原因是对mybatis的list插入不熟悉导致的。目前我还没想明白原因。但是暂时解决了
正确示例
<insert id="insertBillList" parameterType="com.deng.billsystem.pojo.entity.Bill">
insert into bill(userid,username,billdate,breakfastfee,lunchfee,dinnerfee,trafficfee,otherfee,otherfeeremark,createtime,updatetime)
values
<foreach collection="list" item="item" index="index" separator=",">
(
#{item.userId},#{item.username},#{item.billDate},#{item.breakfastFee},
#{item.lunchFee},#{item.dinnerFee},#{item.trafficFee},#{item.otherFee},
#{item.otherFeeRemark},#{item.createTime},#{item.updateTime}
)
</foreach>
</insert>
错误示例