Search code examples
eclipsehibernatejpaeclipse-wtp

Eclipse 3.7 Entity validation error (not in 3.6)


I have about 100 error marker 50 each message. But not every Entity has the error marker The Account class does not have it, but every class that has an Account field. A class with an error prone entity(classes with account fields) as a field does not has this error either.

Class "com.model.AccountChange" is mapped, but is not included in any persistence unit AccountChange.java This marker is on the line of the class definition not the @Entity annotation.

@Entity
public class AccountChange extends BaseObject {

The next error marker is on the line of the @ManyToOne annotation Target entity "com.model.Account" for "account" is not an Entity

@ManyToOne(cascade = { CascadeType.ALL })
@NotNull
private Account account;

I downloaded Eclipse 3.7 Indigo Java EE and installed subclipse and the Jboss Tools 3.3M2.

That project worked fine in Eclipse 3.6 and someone else encountered the same error and switched back to 3.6 but i thought maybe someone knows the source.

EDIT: The first marker could be resolved with Project Properties -> JPA -> Discover annotated classes automatically The other error still persists

EDIT: Thats strange, 57 of the 59 remaining errors are with an Account field. i have in my model classpath a separate persistence.xml. If i Add class com.model.Account i get the error "class cannot be resolved" if i change it to AccountGroup no problems there. The remaining 2 errors cannot be resolved either. The other entities can be.

<?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="project">
<class>com.model.AccountGroup</class>
</persistence-unit>
</persistence>

Solution

  • we have one in the source folder for eclipse development (the one i copied here) and others that replace that file for development or live server.

    That is your issue, JPA Validation currently only supports a single persistent unit or persistence.xml per project:

    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.

    You could try adding <exclude-unlisted-classes>false</exclude-unlisted-classes> to your persistence.xml in your META-INF folder. Conversely, make it true and list all of your entity classes in there not just AccountGroup.