Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Must every Entity Bean be registered in persistence.xml?

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.

like image 203
feder Avatar asked Aug 05 '13 05:08

feder


2 Answers

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.

like image 78
kotev Avatar answered Oct 26 '22 16:10

kotev


in jpa you have to compile a file called persistence.xml where you tell Hibernate which classes will be managed by your ORM.
Check this question and its accepted answer

like image 27
Luca Basso Ricci Avatar answered Oct 26 '22 17:10

Luca Basso Ricci