找准目标,不断前行

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>

 

posted @ 2023-11-30 23:31  kevinZhuZhu  阅读(189)  评论(0编辑  收藏  举报