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?