I am migrating a project from spring boot 1.5.19 to 2.4.5 (which is the current version of my issue).
During this migration process I came across a strange issue regarding an Enum with this stack trace :
Caused by: java.lang.IllegalArgumentException: Unknown name value [] for enum class [***MyBusinessEnum***]
at org.hibernate.type.EnumType$NamedEnumValueMapper.fromName(EnumType.java:433)
at org.hibernate.type.EnumType$NamedEnumValueMapper.getValue(EnumType.java:417)
at org.hibernate.type.EnumType.nullSafeGet(EnumType.java:231)
at org.hibernate.type.CustomType.nullSafeGet(CustomType.java:119)
at org.hibernate.type.AbstractType.hydrate(AbstractType.java:82)
This enum is expected to be null there and should not be mapped using fromName...
Many librairies were upgraded during this process, and I am looking for the culprit, if someone can give me some clues. For example, liquibase as been upgraded from 3.5.5 to 3.10.3 (this is where my next investigation will be). I am in a test context with an h2 database (still the same) and hibernate 5.2.4.Final (still the same).
While debugging, the only difference I saw is that on the old branch before the migration, I had my row like this :
Whereas, in my migration branch, my row look like this :
And unfortunately, ValueLobDb.getString() return "" instead of null for this column... For me, this explain why I get the exception on the enum, but I don't know why the resultSet is not exactly the same... and how I should fix this. I did not changed dataset nor inserted data for this test.
Edit : It seems that the culprit is liquibase : by forcing the version to 3.5.5, it works again... I wonder if it's a liquibase bug or not.
**Edit : The issue appears between 3.5.5 and 3.6.2 (I can't test other versions...) ==> I am still interested for a tip as my goal is to upgrade versions... at least to the one used by spring boot. This would be sad to be stuck with liquibase 3.5.5 **
Well, I managed to make it work with liquibase 3.10.3 (and previous versions until 3.6.2 too...).
Those datas were loaded from a CSV file in a changeset using loadUpdateData. I had to update my changetSet to specify the imported column type like this :
databaseChangeLog:
- changeSet:
id: name
author: me
changes:
- loadUpdateData:
tableName: table
file: file.csv
quotchar: '"'
primaryKey: id
columns:
- column:
name: myColumnWhichIsAnEnumInJava
type: string
I don't really understand why in future liquibase version this is necessary and why this changes the behavior of how H2 is reading the data.
This is not mentioned here : https://docs.liquibase.com/change-types/load-update-data.html
But this seems a bit related to https://liquibase.jira.com/browse/CORE-3287