Jakarta Persistence 3.2 and Hibernate 7+ introduce the @EnumeratedValue annotation, which allows developers to define custom enum mappings by specifying a field to persist instead of relying on enum names or ordinals. This approach eliminates the need for AttributeConverter implementations and prevents database migrations when enum values are renamed, reordered, or modified. The annotation requires each enum constant to have a unique value in the annotated field, ensuring safe and stable persistence without breaking existing data.
Table of contents
Defining a Custom Mapping using @EnumeratedValueUse the @EnumeratedValue mappingSummarySort: