HHH-17017 Hibernate 6 cannot read VARCHAR column as INT
The test shows that using @JdbcTypeCode(SqlTypes.VARCHAR) fixes the issue;
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and can be relicensed under the terms of the LGPL v2.1 license in the future at the maintainers' discretion. For more information on licensing, please check here.
https://hibernate.atlassian.net/browse/HHH-17017
I guess the source of user confusion here is that usually IntegerJavaType will automatically do conversion from String to Integer. EnumJavaType doesn't do such a conversion, it assumes Strings are names, I think because EnumJavaType doesn't actually properly know whether it is an ORDINAL or STRING enum mapping.
I agree with you guys that this is a pretty minor discomfort because the workaround is so easy.
I was wrong, as commented on the Jira, when using @JdbcTypeCode(SqlTypes.VARCHAR) the string value is persisted.
In the Jira I proposed other two solutions.
In previous version it worked because it seems MySQL has no issues using an IntegerJdbcType even when the db column is a varchar, while it has issue when using a TinyIntJdbcType
Ah OK. I think this is slightly less than trivial to fix because as I said:
EnumJavaTypedoesn't actually properly know whether it is anORDINALorSTRINGenum mapping.
But I have not dug deep and so maybe that's wrong.
yes, probably we would need an OrdinalEnumType and a StringEnumType, anyway I think that persisting an oridnal enum into a varchar column is really an edge case
I think that persisting an oridnal enum into a varchar column is really an edge case
I agree.