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)