Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] enum as primary key

Here are a few links that outline using Enums. Also, in the JSR-000220 EJB 3.0 Persistence spec, located under section 9.1.21 Enumerated Annotation, you'll find the outline for the Enumerated annotation. It does not outline specifically the use of Enumerations as PrimaryKeys, but I don't believe that there is any restriction to the use of the annotation.

I hope this helps...

Chris Mathrusse
Sybase, Inc

From: <bht@xxxxxxxxxxxxx>
To: EclipseLink User Discussions <eclipselink-users@xxxxxxxxxxx>
Date: 02/25/2010 07:35 PM
Subject: Re: [eclipselink-users] enum as primary key
Sent by: <eclipselink-users-bounces@xxxxxxxxxxx>

Thanks very much. Your comments are very encouraging.

Would anyone know an EclipseLink documentation reference that
specifies support of enums as primary keys? I would need that when
coding this because the specification does not cover it.



On Thu, 25 Feb 2010 15:33:44 -0800, you wrote:

>When I began our project I tried all 3 providers; EclipseLink, Hibernate
>and OpenJPA. In my opinion, EclipseLink was by far the easiest to get
>operational and I found it had the best documentation. Hibernate required
>some 14 libraries to be included to get things to work and even then the
>behavior wasn't what I expected or received from EclipseLink. OpenJPA was
>easier to configure than Hibernate but I actually never got it working
>correctly. EclipseLink worked as documented and as expected
>out-of-the-box. So all I can really speak to is what I have experienced
>with my use of EclipseLink.
>As far as having the enum included in the JPA spec, I think it would
>clearly be a good idea. As you've already discovered, EclipseLink
>implements this behavior. From my perspective, I don't plan to use any
>other provider so its a non issue for me.
>Chris Mathrusse
>Sybase, Inc
>EclipseLink User Discussions <eclipselink-users@xxxxxxxxxxx>
>02/25/2010 03:26 PM
>Re: [eclipselink-users] enum as primary key
>Sent by:
>Hi Chris,
>I do that, too.
>My wish is to have this included in the JPA spec so that best
>practices are portable. Currently they are't. Have you tried OpenJPA,
>On Thu, 25 Feb 2010 13:33:27 -0800, you wrote:
>>I'm currently using enum as a PrimaryKey in our project with EclipseLink.
>>It's definition is as follows:
>>   @Id @Column(
>>        name       = "ID",
>>        length     = 20
>>    )
>>    @Enumerated( EnumType.STRING )
>>    private Key id;
>>Then just define your enum as you would like.
>>Chris Mathrusse
>>Sybase, Inc
>>EclipseLink User Discussions <eclipselink-users@xxxxxxxxxxx>
>>02/25/2010 11:49 AM
>>[eclipselink-users] enum as primary key
>>Sent by:
>>I am using enum as primary key in TopLink and EclipseLink.
>>The JPA 2.0 specification does not include it in "2.4 Primary Keys and
>>Entity Identity"
>>However, DataNucleus lists it at
>>, assuming in comments that it is standard JPA.
>>Does enyone know of any plans or chance to include this in the
>>specification because, quite honestly, it would be fairly sad not to
>>support it. Enum is a basic language feature, and most applications
>>would enjoy significant benefits by mapping the keys of those little
>>SQL whatever-type lookup tables to enums.
>>Many thanks.
>>eclipselink-users mailing list
>eclipselink-users mailing list

eclipselink-users mailing list

Back to the top