[jpa-spec users] Re: Map Enum to Coded Values and Converters

From: michael keith <>
Date: Fri, 09 Mar 2012 16:57:18 -0500

Hi Andrew,

Yes, converters will be able to handle that case. When we said that
@Enumerated was not permitted on a converted mapping that only meant
that there was no reason for the two annotations to co-reside on the
same attribute. You can convert attributes of any enumerated type in any
way that you wish, including your suggested mappings below.


On 08/03/2012 3:57 PM, Andrew Ward wrote:
> Hi
> Will it be possible to use the proposed AttributeConverter class to
> address the limitation with Enums below? I was hoping this class would
> enable the selection of a custom enum attribute when persisting,
> without using the proprietary extensions in EclipseLink and Hibernate.
> Section 3.7 of the updated spec indicates that @Enumerated will be
> excluded, which would be a shame.
> Thanks
> Andrew
> On 27 Dec 2011, at 21:57, Andrew Ward <
> <>> wrote:
>> Hi Expert Group
>> The current JPA spec provides @Enumerated, with EnumType being
>> limited to ORDINAL and STRING.
>> ORDINAL is not good long term, as enumerations may be expanded, and
>> ordinal positions will change if new literals are inserted. Seems too
>> brittle.
>> STRING is better than ORDINAL, but creates a conflict between the
>> desire for short codes in the database, and meaningful literal names.
>> What users really want is the ability to map an enum literal to a
>> code (a short string, or number).
>> The design problem you have, is how to best specify the custom enum
>> attribute to be used as the code.
>> EclipseLink and Hibernate understand this requirement, and provide
>> proprietary solutions.
>> Is there any chance of standardising this in JPA 2.1?
>> Thanks
>> Andrew Ward