persistence@glassfish.java.net

_at_Id ValidationException with EclipseLink

From: David Nedrow <dnedrow_at_mac.com>
Date: Sun, 13 Jul 2008 23:07:55 -0400

I've got about 10 classes that I have implemented via EclipseLink
(1.0) annotations that all appear to work fine.

I added a new entity, but now I get the following annotation error
when trying to deploy the app in GlassFish (V2.1)...

Deploying application in domain failed; Exception [EclipseLink-28018]
(Eclipse Persistence Services - 1.0 (Build 1.0 - 20080707)):
org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [NetConfPU]
failed.
Internal Exception: Exception [EclipseLink-7161] (Eclipse Persistence
Services - 1.0 (Build 1.0 - 20080707)):
org.eclipse.persistence.exceptions.ValidationException
Exception Description: Entity class [class
com.foo.ncs.argfrp.jpa.netconf.AclAddrDst] 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 please make
sure that you do not have mixed access-type (both fields and
properties annotated) in your entity class hierarchy.


So far as I can tell, I've done everything the same for the entities
I've constructed that work fine.

Can anyone see a problem with what I have below?

/* AbstractAclAddrDst.java */

package com.foo.ncs.argfrp.jpa.netconf;

//~--- JDK imports
------------------------------------------------------------

import javax.persistence.Column;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.MappedSuperclass;
import javax.persistence.SequenceGenerator;

/**
* AbstractAclAddrDst entity provides the base persistence definition
of the
* AclAddrDst entity.
*
*/
@MappedSuperclass public abstract class AbstractAclAddrDst implements
java.io.Serializable {

// Fields
private Integer id;
private FilterAccess filterAccess;
private Integer address;

// Constructors

/** default constructor */
public AbstractAclAddrDst() {}

/** full constructor */
public AbstractAclAddrDst(Integer id, FilterAccess filterAccess,
Integer address) {
this.id = id;
this.filterAccess = filterAccess;
this.address = address;
}

// Property accessors

/**
* Method description
*
*
* @return
*/
@SequenceGenerator(name = "ACLADDRDST_SEQ", sequenceName =
"acl_addr_dst_id_seq")
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator =
"ACLADDRDST_SEQ")
@Id @Column(
name = "id",
unique = true,
nullable = false
)
public Integer getId() {
return this.id;
}

/**
* Method description
*
*
* @param id
*/
public void setId(Integer id) {
this.id = id;
}

/**
* Method description
*
*
* @return
*/
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "filter_accessid", nullable = false)
public FilterAccess getFilterAccess() {
return this.filterAccess;
}

/**
* Method description
*
*
* @param filterAccess
*/
public void setFilterAccess(FilterAccess filterAccess) {
this.filterAccess = filterAccess;
}

/**
* Method description
*
*
* @return
*/
@Column(name = "address", nullable = false)
public Integer getAddress() {
return this.address;
}

/**
* Method description
*
*
* @param address
*/
public void setAddress(Integer address) {
this.address = address;
}
}


//~ Formatted in Sun Code Convention on 2008-07-13



and the concrete class...

/* AclAddrDst.java */


package com.foo.ncs.argfrp.jpa.netconf;

//~--- JDK imports
------------------------------------------------------------

import javax.persistence.Entity;
import javax.persistence.Table;

/**
* AclAddrDst entity.
*
*/
@Entity @Table(name = "acl_addr_dst")
public class AclAddrDst extends AbstractAclAddrDst implements
java.io.Serializable {

// Constructors

/** default constructor */
public AclAddrDst() {}

/** full constructor */
public AclAddrDst(Integer id, FilterAccess filterAccess, Integer
address) {
super(id, filterAccess, address);
}
}


//~ Formatted in Sun Code Convention on 2008-07-13