0

When I create a new Configuration in the "Hibernate Configuration" tab, the Session Factory node correctly shows the entities that are listed in the persistence.xml file of the main project, but fails to find all entities from a library project.

I'm using annotation configuration.

xtian
  • 2,908
  • 2
  • 30
  • 43

1 Answers1

0

This is due to the way persistence.xml works. You can add an external jar to persistence.xml using the <jar-file> element. The tricky bit is to make it work in Eclipse, where compiled classes are spread around different projects. As suggested by this answer, you can do so with a relative "file:" url:

<persistence-unit name="myPersistenceUnit">
<jar-file>file:../../LibraryProject1/bin</jar-file>
<jar-file>file:../../LibraryProject2/bin</jar-file>

The "current folder" is the compiler output folder ("bin" in my case) i.e. the one containing META-INF if persistence.xml is located at /MainProject/src/main/resources/META-INF/persistence.xml

xtian
  • 2,908
  • 2
  • 30
  • 43