休眠 <-> H2。浮动映射异常
Hibernate <-> H2. Float mapping exception
我有 Spring-boot(with 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)]
我试图用 real
替换 float
,float4
它没有帮助我。
我通过为实体使用 BigDecimal 类型和为数据库使用 Number 类型解决了这个问题
我有 Spring-boot(with 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)]
我试图用 real
替换 float
,float4
它没有帮助我。
我通过为实体使用 BigDecimal 类型和为数据库使用 Number 类型解决了这个问题