Upon upgrading from 6.1.7 to 6.2.0, I get this error message during schema validation:
Caused by: org.hibernate.tool.schema.spi.SchemaManagementException: Schema-validation: wrong column type encountered in column [receiving_status] in table [buddies_anonymized]; found [int (Types#INTEGER)], but expecting [tinyint (Types#TINYINT)]
The full class BuddyAnonymized can be found here. The attribute receivingStatus is declared as follows (no annotations applied):
private Status receivingStatus = Status.NOT_REQUESTED;
The type Status is an enum, defined as follows:
public enum Status
{
NOT_REQUESTED, REQUESTED, ACCEPTED, REJECTED
}
This issue I reported on the Hibernate project as HHH-16422. As I didn't get a response yet, I wanted to implement a workaround and explicitly define the column type, like this:
@Column(columnDefinition = "INTEGER")
private Status receivingStatus = Status.NOT_REQUESTED;
However, the same error is still being reported. What is going wrong here?
I got a response from the Hibernate team: This is a documented breaking change in Hibernate 6.2, see the 6.2 migration guide.
The solution is to add the @JdbcType annotation, as follows:
@JdbcType(value = SmallIntJdbcType.class)
private Status receivingStatus = Status.NOT_REQUESTED;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With