Q:

JPA 2: EclipseLink Ant Build Error

I got this error while generating generic for my model via ANT build script:
Internal Exception: Exception [EclipseLink-7161] (Eclipse Persistence Services - 2.2.0.v20110202-r8913): org.eclipse.persistence.exceptions.ValidationException
Exception Description: Entity class [class com.ckd.model.BookModel] 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.

Here's my entity class:
@Entity
@Table(name = "BOOK")
public class BookModel implements Serializable
{
    private static final long serialVersionUID = 1L;

//  @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "ID", unique = true, nullable = false)
    private Long id;

    @Id
    @NotNull
    @Size(min = 32, max = 32)
    @Column(name = "HASHID", unique = true, nullable = false)
    private String hashid;

    @NotNull
    @Size(min = 1, max = 255)
    @Column(name = "TITLE")
    public String title;

    @NotNull
    @Size(min = 1, max = 255)
    @Column(name = "AUTHOR")
    private String author;

    @Lob
    @NotNull
    @Column(name = "CONTENT")
    private String content;

    @Size(min = 2, max = 3)
    @Column(name = "LANG")
    public String lang; 

    // getters and setters here
}

I've also added this to my entity but it makes no difference:
@Entity
@Access(AccessType.FIELD)

Building my project against the bundled-EclipseLink libraries that comes with Glassfish 3.1 or using the EclipseLink v2.x.x standalone libraries from http://www.eclipse.org/eclipselink/downloads/ also make no difference - still got the above error.
My persistence.xml is under WebContent\META-INf directory as per Java EE project requirement. The content of it is:
<?xml version="1.0" encoding="UTF-8"?>
<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 http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
    version="2.0">   
    <persistence-unit name="persistentUnit" transaction-type="JTA">
        <description>Persistent Unit for Entity Classes</description>
        <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
        <jta-data-source>jdbc/prod1</jta-data-source>
        <class>com.ckd.model.BookModel</class>
        <exclude-unlisted-classes>false</exclude-unlisted-classes>
        <properties>
            <property name="eclipselink.jdbc.DBDictionary" value="mysql(DriverVendor=mysql)" />
            <property name="eclipselink.target-database" value="org.eclipse.persistence.platform.database.MySQLPlatform" /> 
            <property name="eclipselink.jdbc.DBDictionary" value="searchStringEscape=\\" /> 
            <property name="eclipselink.jdbc.QuerySQLCache" value="false" />
            <property name="eclipselink.weaving" value="false" /> 
            <property name="eclipselink.logging.logger" value="org.eclipse.persistence.logging.DefaultSessionLog" />
            <property name="eclipselink.logging.level" value="FINEST" /> 
        </properties>
    </persistence-unit>
</persistence>

How can I resolve this error? Is this a bug with the current implementation of EclipseLink 2.x.x?

A:

It was a lone, unused entity entry in orm.xml that caused the above error. Comment out the unused entity entry fixed the error above.

