使用 Spring,當我嘗試運行我的集成測驗時不起作用,因為 H2 資料庫無法創建表。這是錯誤:
org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL "create table foo (id binary not null, bar jsonb, primary key (id))" via JDBC Statement
我的物體定義如下:
@Entity(name = "foo")
@TypeDef(name = "jsonb", typeClass = JsonBinaryType.class)
public class Foo {
@Id
@GeneratedValue(generator = "UUID")
@GenericGenerator(name = "UUID", strategy = "org.hibernate.id.UUIDGenerator")
private UUID id;
@Type(type = "jsonb")
@Column(columnDefinition = "jsonb")
private Object bar;
}
我的型別通過com.vladmihalcea:hibernate-types-52:2.14.0.
我的 h2 版本是com.h2database:h2:2.0.202.
如果我洗掉該bar屬性,它作業正常。
請問有什么線索嗎?
uj5u.com熱心網友回復:
jsonb是 PostgreSQL 資料型別,在 H2 中不可用。它與PG的json資料型別不同,它內部是以二進制結構存盤的,更適合一些操作和索引。
H2 確實有json格式,但https://www.h2database.com/html/datatypes.html#json_type
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/377906.html
