markus
markus

Reputation: 6548

ERROR: Class "test2" is mapped, but is not included in any

I'm getting the error "Class "test2" is mapped, but is not included in any" in eclipse, however the class is included in persistence xml.

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0"
    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">
    <persistence-unit name="test1">
        <class>com.test.domains.test1</class>
        <properties>
                  <!-- properties for schema1 here -->
        </properties>
    </persistence-unit>
    <persistence-unit name="test2">
        <class>com.test.test2</class>
        <properties>
                  <!-- properties for schema 2 here -->
        </properties>
    </persistence-unit>
</persistence>

Why does this error appear. Do I have to configure it different for 2 db schemas?

Upvotes: 1

Views: 2729

Answers (1)

Mikko Maunu
Mikko Maunu

Reputation: 42074

Eclipse (or more specifically Dali) do have limitation, it does not support two persistence units. That is also told in their pages:

Currently Dali only supports one Persistence Unit and one Persistence XML file per project. Other configurations can exist in a JPA project, but the validation and defaults processing may not be correct when multiple persistence units are used.

What it comes to JPA itself, persistence.xml seems to becorrect. There is no need to add same class to two persistence units.

Upvotes: 2

Related Questions