小编Ult*_*ium的帖子

将 PostgreSQL JSONB 类型与 Hibernate Reactive 结合使用

我正在将我的 Quarkus 项目从经典的 Hibernate ORM 迁移到 Hibernate Reactive,并且遇到了 JSONB 字段映射的问题。

这是实体:

@Entity
@TypeDef(name = JsonTypes.JSON_BIN, typeClass = JsonBinaryType::class)
class MyEntity {
    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "myEntityIdGenerator")
    @SequenceGenerator(name = "myEntityIdGenerator", sequenceName = "my_entity_id_seq", allocationSize = 10)
    var id: Long? = null

    // Usage of a plain JsonNode instead of a mapped class is intentional, 
    // as the app receives a request with raw JSON data and should store it without any processing
    @Type(type = JsonTypes.JSON_BIN)
    @NotNull
    lateinit var jsonData: …
Run Code Online (Sandbox Code Playgroud)

postgresql hibernate quarkus hibernate-reactive

1
推荐指数
1
解决办法
2967
查看次数