JPA Attribute Converter – The better way to persist enums
|

JPA Attribute Converter – The better way to persist enums

JPA provides 2 standard mappings for enums, but both have serious downsides. Using the @Enumerated annotation, you can use EnumType.ORDINAL or EnumType.STRING to map the enum value to its database representation. The ordinal of an Enum depends on the ordering of its values and can create problems if we need to add new ones. The…