mybatis解决insert时候空值问题

来源:互联网 发布:沈航网络自助 编辑:程序博客网 时间:2024/05/18 02:49

mybatis在insert的时候,当对象里面有空值的时候,插入不成功,需要在SqlMapperConfig.xml中进行设置;

<setting name="jdbcTypeForNull" value="NULL" />

org.apache.ibatis.exceptions.PersistenceException:

SQL: INSERT INTO USER_S (id,username,birthday,sex,address) VALUES(?,?,?,?,?)

Cause: org.apache.ibatis.type.TypeException: Could not set parameters for mapping: ParameterMapping{property=’address’, mode=IN, javaType=class java.lang.String, jdbcType=null, numericScale=null, resultMapId=’null’, jdbcTypeName=’null’, expression=’null’}. Cause: org.apache.ibatis.type.TypeException: Error setting null for parameter #5 with JdbcType OTHER . Try setting a different JdbcType for this parameter or a different jdbcTypeForNull configuration property. Cause: java.sql.SQLException: 无效的列类型: 1111

0 0