Must every Entity Bean be registered in persistence.xml?

feder picture feder · Aug 5, 2013 · Viewed 12k times · Source

I'm using Eclipse Facets for JPA 2.0 and Hibernate 4.2 implementation. I think I recall that in previous project I would not have to register an Entity Bean in the persistence.xml. Am I mistaken?

Annotating a POJO (in this case Pub.java) with @Entity will throw the following error in the Eclipse marker/problem view:

Class "com.jacky.webapp.model.Pub" is managed, but is not listed in the persistence.xml file    Pub.java    /webapp/src/main/java/com/jacky/webapp/model    

Any clue? thanks.

Answer

kotev picture kotev · Nov 26, 2013

As already written here is the solution:

Check you JPA project properties and be sure to select "Discover annotated classes automatically" in the "Persistent class management" section. Doing this should provide the correct validation for your use case.