0

I am using eclipselink as JPA provider and needs to keep entities in a jar file. All jar entities are annotated with @Entity.I tried false and true but it didn't auto detect the entities. I don't want to write all classes in persistence.xml. Please suggest.

Achyut
  • 377
  • 1
  • 3
  • 17
  • how have you packaged your entities and your persistence.xml.. where is the persistence.xml in relation to the jar and entity classes? The persistence.xml should be in a META-INF directory in with the class files. – Chris Sep 18 '13 at 16:36
  • @Chris It is packaged in the META-INF directory in with the class files. – Achyut Sep 18 '13 at 17:41
  • Check that you don't have another one somewhere else on the classpath that might be being picked up. – Chris Sep 19 '13 at 12:26

1 Answers1

2

It is not expected to work in Java SE environment. In JPA 2.0 specification this is told with following words:

To insure the portability of a Java SE application, it is necessary to explicitly list the managed persistence classes that are included in the persistence unit using the class element ofthe persistence.xml file.

Mikko Maunu
  • 41,366
  • 10
  • 132
  • 135