mybatis mysql Data truncation: Incorrect integer value: '' for column 'xxx' at row 1
com.mysql.jdbc.MysqlDataTruncation: Data truncation: Incorrect integer value: '' for column 'n_before_group_id' at row 1
mybatis foreach 插入时出现这个报错,原因是某字段插入空值时需要插入NULl而不是‘’
解决办法:
<choose> <when test="item.xxx == null || item.xxx == ''"> NULL, </when> <otherwise> #{item.xxx}, </otherwise> </choose>