最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

java - Migration to Hibernate 6 with Micronaut: PostgreSQL Enum Type Mapping Issue - Stack Overflow

programmeradmin2浏览0评论

I'm in the process of migrating my application to Hibernate 6 and I'm using Micronaut. I have an entity that was previously annotated with:

@TypeDef(
    name = "pgsql_enum",
    typeClass = PostgreSQLEnumType.class
)

And an enum field in my entity like this:

@Enumerated(EnumType.STRING)
@Column(name = "status")
@Type(type = "pgsql_enum")
private StatusEnum status;`

My StatusEnum is defined as:

public enum StatusEnum {
    APPROVAL,
    ACTIVE,
    COMPLETED,
}

In PostgreSQL, my enum is defined as:

CREATE TYPE book.book_status_enum AS ENUM (
    'APPROVAL',
    'ACTIVE',
    'COMPLETED'
);

Since migrating to Hibernate 6, I've encountered the following error:

operator does not exist: book.book_status_enum = character varying

When I remove the @Enumerated(EnumType.STRING) annotation, I encounter:

operator does not exist: book.book_status_enum = integer

I have tried various approaches including using converters, @Type, JdbcType, @Enumerated, and columnDefinition, but all lead to the same error.

What I've Tried:

  • Using @Enumerated(EnumType.STRING)
  • Creating a custom jakarta converter
  • Using @JdbcTypeCode(SqlTypes.ENUM) and @Type(PostgreSQLEnumType.class)
  • Specifying columnDefinition in the @Column annotation

None of these approaches have resolved the issue.

How can I correctly map my StatusEnum to the PostgreSQL enum type book.book_status_enum in Hibernate 6 while using Micronaut?

发布评论

评论列表(0)

  1. 暂无评论