Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » has no primary key specified. It should define either an @Id, @EmbeddedId or an @IdClass
has no primary key specified. It should define either an @Id, @EmbeddedId or an @IdClass [message #759787] Wed, 30 November 2011 04:50 Go to next message
Saul  is currently offline Saul
Messages: 2
Registered: November 2011
Junior Member
I'm getting the following error of a an entity class that was generated from a view. I'm new to EclipseLink and am not sure I understand the error. I'm pretty sure I indicated my primary key correctly but I'm not sure about the mixed access-type problem.

run:
Exception in thread "main" Local Exception Stack:
Exception [EclipseLink-30005] (Eclipse Persistence Services - 2.3.1.v20111018-r10243): org.eclipse.persistence.exceptions.PersistenceUnitLoadingException
Exception Description: An exception was thrown while searching for persistence archives with ClassLoader: sun.misc.Launcher$AppClassLoader@138d107f
Internal Exception: javax.persistence.PersistenceException: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.3.1.v20111018-r10243): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [CimsDbLibraryPU] failed.
Internal Exception: Exception [EclipseLink-7161] (Eclipse Persistence Services - 2.3.1.v20111018-r10243): org.eclipse.persistence.exceptions.ValidationException
Exception Description: Entity class [class com.controlpoint.ldb.GetDOMaintenanceIssueListVW] 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.PersistenceUnitLoadingException.exceptionSearchingForPersistenceResources(PersistenceUnitLoadingException.java:127)
at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:115)
at javax.persistence.Persistence.createEntityManagerFactory(Unknown Source)
at javax.persistence.Persistence.createEntityManagerFactory(Unknown Source)
at com.controlpoint.examples.Queries.getMaintenanceIssueDetailVW(Queries.java:103)
at com.controlpoint.examples.Queries.main(Queries.java:63)
Caused by: javax.persistence.PersistenceException: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.3.1.v20111018-r10243): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [CimsDbLibraryPU] failed.
Internal Exception: Exception [EclipseLink-7161] (Eclipse Persistence Services - 2.3.1.v20111018-r10243): org.eclipse.persistence.exceptions.ValidationException
Exception Description: Entity class [class com.controlpoint.ldb.GetDOMaintenanceIssueListVW] 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.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:1402)
at org.eclipse.persistence.internal.jpa.deployment.JPAInitializer.callPredeploy(JPAInitializer.java:98)
at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:105)
... 4 more
Caused by: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.3.1.v20111018-r10243): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [CimsDbLibraryPU] failed.
Internal Exception: Exception [EclipseLink-7161] (Eclipse Persistence Services - 2.3.1.v20111018-r10243): org.eclipse.persistence.exceptions.ValidationException
Exception Description: Entity class [class com.controlpoint.ldb.GetDOMaintenanceIssueListVW] 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.EntityManagerSetupException.predeployFailed(EntityManagerSetupException.java:221)
... 7 more
Caused by: Exception [EclipseLink-7161] (Eclipse Persistence Services - 2.3.1.v20111018-r10243): org.eclipse.persistence.exceptions.ValidationException
Exception Description: Entity class [class com.controlpoint.ldb.GetDOMaintenanceIssueListVW] 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:1392)
at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EntityAccessor.validatePrimaryKey(EntityAccessor.java:1330)
at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EntityAccessor.processMappingAccessors(EntityAccessor.java:1067)
at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EntityAccessor.process(EntityAccessor.java:631)
at org.eclipse.persistence.internal.jpa.metadata.MetadataProject.processStage2(MetadataProject.java:1645)
at org.eclipse.persistence.internal.jpa.metadata.MetadataProcessor.processORMMetadata(MetadataProcessor.java:532)
at org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor.processORMetadata(PersistenceUnitProcessor.java:526)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:1337)
... 6 more
Java Result: 1
BUILD SUCCESSFUL (total time: 1 second)


Here's my class.

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.controlpoint.ldb;

import java.io.Serializable;
import java.math.BigInteger;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
*
* @author gonzalez
*/
@Entity
@Table(name = "GetDOMaintenanceIssueList_VW", catalog = "ldbtest", schema = "ldb")
@XmlRootElement
@NamedQueries({
@NamedQuery(name = "GetDOMaintenanceIssueListVW.findAll", query = "SELECT g FROM GetDOMaintenanceIssueListVW g"),
@NamedQuery(name = "GetDOMaintenanceIssueListVW.findByRowID", query = "SELECT g FROM GetDOMaintenanceIssueListVW g WHERE g.rowID = :rowID"),
@NamedQuery(name = "GetDOMaintenanceIssueListVW.findBySourceCRISSiteID", query = "SELECT g FROM GetDOMaintenanceIssueListVW g WHERE g.sourceCRISSiteID = :sourceCRISSiteID"),
@NamedQuery(name = "GetDOMaintenanceIssueListVW.findByMaintenanceIssueGUID", query = "SELECT g FROM GetDOMaintenanceIssueListVW g WHERE g.maintenanceIssueGUID = :maintenanceIssueGUID"),
@NamedQuery(name = "GetDOMaintenanceIssueListVW.findByEventTypeName", query = "SELECT g FROM GetDOMaintenanceIssueListVW g WHERE g.eventTypeName = :eventTypeName"),
@NamedQuery(name = "GetDOMaintenanceIssueListVW.findByMaintenanceIssueName", query = "SELECT g FROM GetDOMaintenanceIssueListVW g WHERE g.maintenanceIssueName = :maintenanceIssueName"),
@NamedQuery(name = "GetDOMaintenanceIssueListVW.findByActiveStatus", query = "SELECT g FROM GetDOMaintenanceIssueListVW g WHERE g.activeStatus = :activeStatus"),
@NamedQuery(name = "GetDOMaintenanceIssueListVW.findByMissionCriticality", query = "SELECT g FROM GetDOMaintenanceIssueListVW g WHERE g.missionCriticality = :missionCriticality"),
@NamedQuery(name = "GetDOMaintenanceIssueListVW.findBySeverity", query = "SELECT g FROM GetDOMaintenanceIssueListVW g WHERE g.severity = :severity"),
@NamedQuery(name = "GetDOMaintenanceIssueListVW.findByDetectionMethod", query = "SELECT g FROM GetDOMaintenanceIssueListVW g WHERE g.detectionMethod = :detectionMethod"),
@NamedQuery(name = "GetDOMaintenanceIssueListVW.findByResolutionStatus", query = "SELECT g FROM GetDOMaintenanceIssueListVW g WHERE g.resolutionStatus = :resolutionStatus"),
@NamedQuery(name = "GetDOMaintenanceIssueListVW.findByCapability", query = "SELECT g FROM GetDOMaintenanceIssueListVW g WHERE g.capability = :capability"),
@NamedQuery(name = "GetDOMaintenanceIssueListVW.findByUpdateDate", query = "SELECT g FROM GetDOMaintenanceIssueListVW g WHERE g.updateDate = :updateDate")})
public class GetDOMaintenanceIssueListVW implements Serializable {
private static final long serialVersionUID = 1L;
@Column(name = "Row_ID")
@Id
private BigInteger rowID;
@Size(max = 16)
@Column(name = "Source_CRIS_Site_ID", length = 16)
private String sourceCRISSiteID;
@Basic(optional = false)
@NotNull
@Size(min = 1, max = 36)
@Column(name = "Maintenance_Issue_GUID", nullable = false, length = 36)
private String maintenanceIssueGUID;
@Basic(optional = false)
@NotNull
@Size(min = 1, max = 50)
@Column(name = "Event_Type_Name", nullable = false, length = 50)
private String eventTypeName;
@Basic(optional = false)
@NotNull
@Size(min = 1, max = 50)
@Column(name = "Maintenance_Issue_Name", nullable = false, length = 50)
private String maintenanceIssueName;
@Basic(optional = false)
@NotNull
@Size(min = 1, max = 50)
@Column(name = "Active_Status", nullable = false, length = 50)
private String activeStatus;
@Size(max = 80)
@Column(name = "Mission_Criticality", length = 80)
private String missionCriticality;
@Basic(optional = false)
@NotNull
@Size(min = 1, max = 50)
@Column(name = "Severity", nullable = false, length = 50)
private String severity;
@Basic(optional = false)
@NotNull
@Size(min = 1, max = 50)
@Column(name = "Detection_Method", nullable = false, length = 50)
private String detectionMethod;
@Basic(optional = false)
@NotNull
@Size(min = 1, max = 50)
@Column(name = "Resolution_Status", nullable = false, length = 50)
private String resolutionStatus;
@Size(max = 50)
@Column(name = "Capability", length = 50)
private String capability;
@Column(name = "Update_Date")
@Temporal(TemporalType.TIMESTAMP)
private Date updateDate;

public GetDOMaintenanceIssueListVW() {
}

public BigInteger getRowID() {
return rowID;
}

public void setRowID(BigInteger rowID) {
this.rowID = rowID;
}

public String getSourceCRISSiteID() {
return sourceCRISSiteID;
}

public void setSourceCRISSiteID(String sourceCRISSiteID) {
this.sourceCRISSiteID = sourceCRISSiteID;
}

public String getMaintenanceIssueGUID() {
return maintenanceIssueGUID;
}

public void setMaintenanceIssueGUID(String maintenanceIssueGUID) {
this.maintenanceIssueGUID = maintenanceIssueGUID;
}

public String getEventTypeName() {
return eventTypeName;
}

public void setEventTypeName(String eventTypeName) {
this.eventTypeName = eventTypeName;
}

public String getMaintenanceIssueName() {
return maintenanceIssueName;
}

public void setMaintenanceIssueName(String maintenanceIssueName) {
this.maintenanceIssueName = maintenanceIssueName;
}

public String getActiveStatus() {
return activeStatus;
}

public void setActiveStatus(String activeStatus) {
this.activeStatus = activeStatus;
}

public String getMissionCriticality() {
return missionCriticality;
}

public void setMissionCriticality(String missionCriticality) {
this.missionCriticality = missionCriticality;
}

public String getSeverity() {
return severity;
}

public void setSeverity(String severity) {
this.severity = severity;
}

public String getDetectionMethod() {
return detectionMethod;
}

public void setDetectionMethod(String detectionMethod) {
this.detectionMethod = detectionMethod;
}

public String getResolutionStatus() {
return resolutionStatus;
}

public void setResolutionStatus(String resolutionStatus) {
this.resolutionStatus = resolutionStatus;
}

public String getCapability() {
return capability;
}

public void setCapability(String capability) {
this.capability = capability;
}

public Date getUpdateDate() {
return updateDate;
}

public void setUpdateDate(Date updateDate) {
this.updateDate = updateDate;
}

}
Re: has no primary key specified. It should define either an @Id, @EmbeddedId or an @IdClass [message #759860 is a reply to message #759787] Wed, 30 November 2011 11:16 Go to previous message
Matti Hansson is currently offline Matti Hansson
Messages: 68
Registered: July 2009
Member
Have you made sure the class com.controlpoint.ldb.GetDOMaintenanceIssueListVW is listed in persistence.xml? I believe you can get that error message if it isn't.

[Updated on: Wed, 30 November 2011 11:17]

Report message to a moderator

Previous Topic:has no primary key specified. It should define either an @Id, @EmbeddedId or an @IdClass
Next Topic: Join on concatenated columns
Goto Forum:
  


Current Time: Sat Oct 25 15:28:05 GMT 2014

Powered by FUDForum. Page generated in 0.02919 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software