今天碰到一个bug记录下。oracle合并数据插入的时候报错。
Cause: java.sql.SQLSyntaxErrorException: ORA-01790: expression must have same datatype as corresponding expression
oracle 使用 union all合并的时候。
如果表字段是DATE类型。合并数据的时候一条是NULL,一条是日期。提示上面的报错。
解决方案是 mybatis 指定 jdbcType。这样统一类型就没有问题了
#{item.expireDate, jdbcType=DATE},
#{item.produceDate, jdbcType=DATE},