Mybatis插入操作对空值的处理
Mapper.xml
<insert id="AddNewCar" parameterType="com.xxx.entity.Car" useGeneratedKeys="true" keyProperty="cid">
insert into car(brand,model,price,time,pic,color,age,location,mile)
values (#{brand},#{model},#{price},#{time},#{pic},
#{color,jdbcType=VARCHAR},#{age,jdbcType=INTEGER},#{location,jdbcType=VARCHAR},#{mile,jdbcType=INTEGER})
</insert>
mybatis-config.xml
在configuration标签里
<settings>
<setting name="jdbcTypeForNull" value="NULL" />
</settings>