Description
Fábio Coutinho Valente opened DATAJDBC-408 and commented
I'm changing my application from Spring Data JPA to Spring Data JDBC, and I have one column on my table that saves an integer of the ordinal.
According to documentation Spring Data JDBC only allows converting enums to string out of the box. So I tried a workaround with custom converters.
I created a custom converter with @ReadingConverter
and could read/convert properly to my enum value according to the integer on my table.
I tried creating a custom converter with @WritingConverter
annotation, but its not being executed instead the converter org.springframework.core.convert.support.EnumToStringConverter is being called.
After some debugging I found the map javaToDbType in class BasicRelationalPersistentProperty to be the resposible for that due to this static line
javaToDbType.put(Enum.class, String.class)
If there is no built-in convertion enum to integer, could you allow custom converter to be used instead?
Is there any other way to convert enum values into integer (ordinal number)?
2 votes, 3 watchers