Hibernate 6 / Wrong column type encountered for Enum / Postgresql /int4 vs smallint

Hi,

After upgrading to Hibernate 6, my application does not start due to a schema validation error.

Schema-validation: wrong column type encountered in column [status]
in table [Usr]; found [int4 (Types#INTEGER)],
but expecting [smallint (Types#TINYINT)]

The User entity has an enum property “status”, and the type of the column “status” in PostgreSQL is an integer.

This code works with Hibernate 5 but does not work with Hibernate 6.

I tried to force the type with a “columnDefinition” like below but that does not work:

@Entity
@Table(name = "Usr")
public class User {
  ...
  @NotNull
  @Enumerated(EnumType.ORDINAL)
  @Column(columnDefinition = "integer")
  private UserStatus status;
  ...
}
public enum UserStatus {
    OK, UNAUTHORIZED
}

Is it a bug?

Hibernate 6.1 changed the implicit SQL datatype for mapping enums from TINYINT to SMALLINT

I don’t know if the @Column(columnDefinition = "integer") is supposed to work, I will change the type of column.