I have a Entity class and jpa is throwing an Validation Exception saying primary key specified. I could not figure out why.
Please see the details below: * Internal Exception: javax.persistence.PersistenceException: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.4.2.v20130514-5956486): org.eclipse.persistence.exceptions.EntityManagerSetupException Exception Description: Predeployment of PersistenceUnit [default] failed. Internal Exception: Exception [EclipseLink-7161] (Eclipse Persistence Services - 2.4.2.v20130514-5956486): org.eclipse.persistence.exceptions.ValidationException Exception Description: Entity class [class A] 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.*
The entity class A:
@Access(AccessType.FIELD)
@Entity
@Cache(disableHits=true)
@Table(name="VT_INVALID_USERS")
public class A extends BharosaBaseBean implements java.io.Serializable {
@SequenceGenerator(name="USERS_SEQ", allocationSize=1)
@Id
@GeneratedValue(strategy=GenerationType.AUTO, generator="USERS_SEQ")
@Column(name="USER_ID")
protected Long userId;
@Temporal(TemporalType.TIMESTAMP)
@Column(name="CREATE_TIME")
protected Date createTime = new Date();
public void setUserId( Long userId ) {
this.userId = userId;
}
public Long getUserId( ) {
return this.userId;
}
}
The BharosaBaseBean class:
public abstract class BharosaBaseBean implements java.io.Serializable {
abstract public Long getPKId();
}
The persistence file I have:
<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence persistence_1_0.xsd" version="1.0">
<persistence-unit name="default" transaction-type="RESOURCE_LOCAL">
<provider>
org.eclipse.persistence.jpa.PersistenceProvider
</provider>
<mapping-file>orm.xml</mapping-file>
<properties>
<property name="eclipselink.logging.level" value="FINE"/>
<property name="javax.persistence.jdbc.driver" value="oracle.jdbc.driver.OracleDriver"/>
<property name="javax.persistence.jdbc.url" value=" <url>"/>
<property name="javax.persistence.jdbc.user" value="<user>"/>
<property name="javax.persistence.jdbc.password" value="<pwd>"/>
<property name="eclipselink.jdbc.read-connections.max" value="5"/>
<property name="eclipselink.jdbc.read-connections.min" value="5"/>
<property name="eclipselink.jdbc.write-connections.max" value="10"/>
<property name="eclipselink.jdbc.wirte-connections.min" value="10"/>
<property name="eclipselink.session.customizer" value="oracle.security.uas.core.common.toplink.SessionCustomizerForCLIRetryLogic"/>
<property name="oaam.eclipselink.conn.health.validated.on.error" value="true"/>
<property name="oaam.eclipselink.query.retry.attempt.count" value="3"/>
<property name="oaam.eclipselink.delay.between.reconnect.attempts" value="5000"/>
<property name="oaam.eclipselink.ping.sql" value="select 1 from dual"/>
</properties>
</persistence-unit>
</persistence>