When upgrading from Hibernate 5 to Hibernate 6, the following column/java type causes failures:
public enum Mode { A, S, R };
@Enumerated(EnumType.STRING)
@Column(length = 1)
@JdbcType(VarcharJdbcType.class)
Mode mode;
The column type in the DB is a varchar(1). In Hibernate 5, it considered this column a String and successfully converts to a Mode enum without any intervention. In Hibernate 6, it considers the column a java.lang.Character and thus cannot convert it to a Mode. I’ve tried using an AttributeConverter<Mode, String> but it doesn’t seem to work in all cases. Especially when the column is used in a composite key.
The only fix I’ve found is to change the db column to a varchar(4) and the @Column to a length =4. It’s not ideal but it works.
I’m currently using 6.2.2.Final