4

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

9
  • Did you generate the table using hibernate DDL or SQL query? Your data type for the column is set to SMALLINT but here you will INT. Commented Oct 11, 2020 at 13:59
  • in postgres table column is smallint and I can't change it. Commented Oct 11, 2020 at 14:01
  • I want put enum entity but it requires int type Commented Oct 11, 2020 at 14:02
  • Is this a requirement to store the enum's ordinal values in a column of type SMALLINT or you don't know how to change the data type for that column? Commented Oct 11, 2020 at 14:05
  • I know how to change column to int, but I have no permission to do it. Commented Oct 11, 2020 at 14:06

1 Answer 1

12

Add columnDefinition="int2" at OrderStatus in your entity.

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

Tested on spring boot 2.2.10

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.