12

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.

feder
  • 1,775
  • 5
  • 25
  • 36

3 Answers3

33

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.

kotev
  • 331
  • 3
  • 3
1

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

Community
  • 1
  • 1
Luca Basso Ricci
  • 17,829
  • 2
  • 47
  • 69
  • 1
    Bellabax, I noticed, that you could tag the classes to overcome the object-relational impedance. However, that is declarative, and I'd rather apply the annotation style. I just got confirmed from a co-worker, that my assumption/memory is true. No need to register classes manually in the peristence.xml or orm.xml if you use annotations. Presumably, this error must be an Eclipse (4.3 Kepler) error. – feder Aug 05 '13 at 06:30
  • But is your code work fine during run? I thought you have problem during execution. Probably you are right and is just an eclipse validator problem – Luca Basso Ricci Aug 05 '13 at 06:53
  • Yes, works fine when manually deployed (Eclipse refuses to deploy errornous WARs). Yes, looks like a Kepler error. I try with Juno later this day. – feder Aug 05 '13 at 07:45
  • Lookup [here](https://bugs.eclipse.org/bugs/show_bug.cgi?format=multiple&id=392702): maybe is a voluntary warning message... – Luca Basso Ricci Aug 05 '13 at 07:53
  • Yes, I previously wrote Karen (Dali developer) about it. – feder Aug 05 '13 at 09:25
0

It's possible when you created the project, you picked "JPA project" instead of "java Project". In case you don't see "Java Project", follow the "other" and under the wizard type "java" to see the "Java Project".

Arash
  • 1
  • 1