Skip to content
Advertisement

Jpa Enum error with Smallint type in postgres

I want to put enum in my entity. But I have an error with validation which JPA wonts smallint set as enum. How I can solve this issue.

“Schema-validation: wrong column type encountered in column [status] in table [order]; found [int2 (Types#SMALLINT)], but expecting [int4 (Types#INTEGER)]”[enter image description here] enter image description here

enter image description here

Advertisement

Answer

Add columnDefinition=”int2″ at OrderStatus in your entity.

    @Column(name = "status", columnDefinition = "int2")
    OrderStatus status;

Tested on spring boot 2.2.10

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement