3

I have a JavaEE project with several entities with the following persistence.xml file:

...
<properties>
    <!-- Scan for annotated classes -->
    <property name="hibernate.archive.autodetection" value="class"/>
...

And it seems to work. The project is then deployed as a JAR to two different projects. In one them, the persistence.xml file is basically the same as the one above, i.e. uses the autodetection feature of Hibernate. However, it does not seem to work (because I think it needs to load search for the entities in a jar). When I tried manually listing all the entities in both xml files, everything works correctly.

Edit: It works with jar-file but only with the absolute path to the jar. Pretty useless for a team project.

4

3 に答える 3

3

私が正しく読んだ場合、それが機能しない場合、エンティティは使用されているpersistence.xmlとは異なるJARにありますよね?

私はあなたが正しいと思います。それが問題です。jar-file要素を使用して、どの JAR をスキャンするかを Hibernate に指示する必要があります。ここの Hibernate ドキュメントの説明と例を参照してください。

于 2013-08-02T09:14:11.210 に答える