Reputation: 9191
I am using eclipse. I am trying to debug a failure to find the persistence unit that is indeed located in the directory structure of my eclipse project.
Where does EntityManagerFactory javax.persistence.Persistence.createEntityManagerFactory(String persistenceUnitName, Map properties)
look for the persistence unit?
When I ask where it looks, I mean all the possible resources that could get searched, including eclipse configurations, properties in persistence.xml if the file is found, resources searched by included JARs, etc. To explore how this works, I am executing a test program by right clicking on a Main.java class located in the root (src/main/java
) of an eclipse project.
The answer might help me figure out how to configure the eclipse project so that EntityManagerFactory javax.persistence.Persistence.createEntityManagerFactory(String persistenceUnitName, Map properties)
can find the persistence unit.
Upvotes: 8
Views: 23468
Reputation: 3500
It searches your persistence.xml, located inside your META-INF dir. This folder has to be at the same level as your root package.
In a maven project, the folder would be in /src/main/resources/META-INF/persistence.xml
Upvotes: 6