We have a fairly common forwards-compatibility scenario that makes using enums problematic: loading unknown enum values results in an exception during loading.
These "unknown" enum values are just values written by "future" versions of our application.
In cases where it really matters, we use feature flagging to ensure such values don't get written until old versions of the application are shutdown.
However, there are many cases where we'd really just like the unknown value to be loaded as "unknown", and not cause loading to fail.
Of course, we can always handle "enums" by just treating them as strings, but that approach loses out on type safety in Java/Scala and schema validation in the database.
A couple of alternate approaches I've been wondering about:
1. Load/store enums as Either<Integer, EnumType> or Either<String, EnumType> (depending on the underlying database enum type). This approach allows the client to inspect the unknown value if need be, round-trip it, or pass it along if it doesn't really need to know about the enum values.
2. Map unknown enum values to a customizable UNKNOWN enum value. This could be built into jOOQ generated enum types, and configurable for user-generated enum types. This approach wouldn't allow for client inspection of the unknown value, or passing it along, or round tripping - store operations would have to fail when trying to store such an unknown value.
Looking for some feedback on those approaches, and whether they can be implemented in jOOQ 3.10 through customization, and whether some variation of the above might make sense to be built into jOOQ?
Thanks!