1. Null值问题
当数据允许为null时,需要指定数据类型
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.type.TypeException: Could not set parameters for mapping: ParameterMapping{property='stationContact', 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 #10 with JdbcType OTHER . Try setting a different JdbcType for this parameter or a different jdbcTypeForNull configuration property. Cause: java.sql.SQLException: 无效的列类型
tkMybatis并不支持 @Column中指定的允许为null,需要使用自己的@ColumnType。
@ColumnType(column ="CN_ORDER_CODE",jdbcType= JdbcType.VARCHAR)
2. MapperScan 在springboot 启动中使用的mapperScan注意是tk包。
3. id
id采用jpa标准中的@ID,但是在主键策略上不一样,可根据错误提示,填写正确的id值。
4. 列使用关键字
java.sql.SQLException: ORA-01747: user.table.column, table.column 或列说明无效
Oracle下
@ColumnType(column ="\"DESC\"",jdbcType= JdbcType.VARCHAR)
Mysql下
@ColumnType(column ="`DESC`",jdbcType= JdbcType.VARCHAR)