Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 330650 - @Id annotated fields with @NotNull not recognized as primary key fields.
Summary: @Id annotated fields with @NotNull not recognized as primary key fields.
Status: CLOSED DUPLICATE of bug 324408
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: All Mac OS X - Carbon (unsup.)
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Nobody - feel free to take it CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-11-19 06:37 EST by Maarten Billemont CLA
Modified: 2022-06-09 10:35 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Maarten Billemont CLA 2010-11-19 06:37:19 EST
Build Identifier: 2.1.1.v20100817-r8050

I've got an entity with a primary key annotated with org.jetbrains' NotNull annotation.  When I deploy this code, EclipseLink fails to find a primary key in the entity.  Removing the @NotNull fixes this issue.

Code:

@Entity
public class Promotion implements Serializable {

    @Id
    @NotNull
    private final String             name;

    ...
}

Exception:

Exception Description: Entity class [class net.link.redbutton.server.scheduler.data.Promotion] has no primary key specified. It should define either an @Id, @EmbeddedId or an @IdClass. If you have defined PK using any of these annotations then make sure that you do not have mixed access-type (both fields and properties annotated) in your entity class hierarchy.
        at org.eclipse.persistence.exceptions.ValidationException.noPrimaryKeyAnnotationsFound(ValidationException.java:1374) [eclipselink-2.1.1.jar:2.1.1.v20100817-r8050]
        at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EntityAccessor.validatePrimaryKey(EntityAccessor.java:1366) [eclipselink-2.1.1.jar:2.1.1.v20100817-r8050]
        at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EntityAccessor.processAccessors(EntityAccessor.java:885) [eclipselink-2.1.1.jar:2.1.1.v20100817-r8050]
        at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EntityAccessor.process(EntityAccessor.java:691) [eclipselink-2.1.1.jar:2.1.1.v20100817-r8050]
        at org.eclipse.persistence.internal.jpa.metadata.MetadataProject.processStage2(MetadataProject.java:1531) [eclipselink-2.1.1.jar:2.1.1.v20100817-r8050]
        at org.eclipse.persistence.internal.jpa.metadata.MetadataProcessor.processORMMetadata(MetadataProcessor.java:474) [eclipselink-2.1.1.jar:2.1.1.v20100817-r8050]
        at org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor.processORMetadata(PersistenceUnitProcessor.java:441) [eclipselink-2.1.1.jar:2.1.1.v20100817-r8050]
        at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:959) [eclipselink-2.1.1.jar:2.1.1.v20100817-r8050]
        ... 31 common frames omitted

Reproducible: Always

Steps to Reproduce:
1. Make a valid entity class.
2. Put @NotNull or @Nullable from org.jetbrains.annotations on the @Id
3. Open a persistence session.
Comment 1 Frank Schwarz CLA 2010-11-19 14:19:22 EST
Duplicate of Bug 324862?
Comment 2 Maarten Billemont CLA 2010-11-19 14:29:43 EST
Seems unlikely; I'm not seeing any IndexOutOfBounds exception, for one.
Comment 3 Frank Schwarz CLA 2010-11-19 14:52:48 EST
Bug 324408? The common denominator is @Retention(RetentionPolicy.CLASS) (http://grepcode.com/file/repository.jboss.com/maven2/org.jetbrains/annotations/7.0.2/org/jetbrains/annotations/NotNull.java)
Comment 4 Maarten Billemont CLA 2010-11-20 05:58:28 EST
Yup; looks like that'd be it.
Comment 5 Guy Pelletier CLA 2010-11-23 14:03:07 EST

*** This bug has been marked as a duplicate of bug 324408 ***
Comment 6 Eclipse Webmaster CLA 2022-06-09 10:16:52 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink
Comment 7 Eclipse Webmaster CLA 2022-06-09 10:35:09 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink