Class "model.Address" is listed in the persistence.xml file but not mapped

Viewed 63042

I have created a JPA project. In that Eclipse displays the following error on the entity class.

Class "model.Address" is listed in the persistence.xml file but not mapped

How am I supposed to map the entity class in persistance.xml?

Here is the model.Address entity:

package model;

import java.io.Serializable;

import javax.persistence.*;

@Entity
public class Address implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE)
    private long id;
    private String city;
    private String country;
    private String province;
    private String postalCode;
    private String street;

    // Getters/setters omitted for brevity.
}

Here is the persistence.xml:

<?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" 
>
    <provider>org.eclipse.persistance.example.jpa.20.employee.annotations</provider>

    <persistence-unit name="employee" transaction-type="RESOURCE_LOCAL">
        <class>model.Employee</class>
        <class>model.Address</class>

        <properties>
            <property name="javax.persistence.jdbc.driver" value="oracle.jdbc.OracleDriver" />
            <property name="javax.persistence.jdbc.url" value="jdbc:oracle:thin:@localhost:1521:orcl" />
            <property name="javax.persistence.jdbc.user" value="scott" />
            <property name="javax.persistence.jdbc.password" value="tiger" />
        </properties>
    </persistence-unit>
</persistence>
9 Answers

I think you have the wrong JPA provider class. It has to be:

<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>

(the one you've set doesn't seem to be a class at all, let alone a provider class)

Related