I have found a very strange behaviour of Hibernate schema validation for PostgreSQL database:
I have created a column:
ALTER TABLE Country ADD code CHAR(2) NOT NULL DEFAULT 'US'I have added mapping:
@Column(nullable = false, columnDefinition = "CHAR(2)") private String country;And now I get this strange error:
Schema-validation: wrong column type encountered in column [code] in table [Country]; found [bpchar (Types#CHAR)], but expecting [char(2) (Types#VARCHAR)]
On MySQL this works without a problem.
For some strange reason Hibernate reads CHAR(2) column definition as a VARCHAR expectation. This seems obviously wrong but maybe I am missing something.
Is there a way to trigger correct Hibernate behaviour (so it correctly validates schema like in case of MySQL)? Is there a workaround that would allow to turn off validation for specific column/class?
This problem is similar to Quarkus with hibernate found [bpchar (Types#CHAR)], but expecting [char (Types#VARCHAR)] but this time the problem is with PostgreSQL and from correct MySQL behavior I suspect something was fixed on Hibernate side since that question was asked.