我有一个Spring-boot(带有Kotlin
)项目,出于测试目的,我正在使用H2数据库。
Field
在我的实体中
@Column
var cargoWeightAmount: Float? = null
DDL
部分来自flyway
脚本
create table pi_picargo_awb (..., cargo_weight_amount float, ...)
如果我有hibernate.ddl-auto: update
没问题,则映射工作正常。但是,如果我有hibernate.ddl-auto: validate
,则会收到此错误-> Schema-validation: wrong column type encountered in column [cargo_weight_amount] in table [pi_picargo_awb]; found [real (Types#REAL)], but expecting [float4 (Types#FLOAT)]
我尝试将float
替换为real
,float4
并没有帮助我。
答案 0 :(得分:0)
我通过为实体使用 BigDecimal 类型和为数据库使用 Number 类型解决了这个问题