JPA @Entityアノテーションを利用して、クラスエンティティにJ2SEのpersistence.xmlファイルを宣言しないことを望みます。私は避けたいのですが:ここpersistence.xmlファイルで永続クラスを宣言しないようにJPAエンティティをスキャンする方法はありますか?
<persistence-unit name="test" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<class>com.mycompany.entities.Class1</class>
<class>com.mycompany.entities.Class2</class>
<class>com.mycompany.entities.Class3</class>
</persistence-unit>
と私の実際のpersistence.xmlが
<persistence-unit name="test" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<properties>
<!-- Scan for annotated classes and Hibernate mapping XML files -->
<property name="hibernate.archive.autodetection" value="class, hbm" />
<property name="hibernate.cache.use_second_level_cache" value="false" />
<property name="hibernate.cache.use_query_cache" value="false" />
<property name="hibernate.hbm2ddl.auto" value="create-drop" />
</properties>
</persistence-unit>
内からpersistence.xmlファイルでJPAエンティティをスキャンする標準的な方法があります似て何をされますJARモジュール? JARモジュール内のpersistence.xmlファイル内のJPAエンティティをスキャンするための非標準のHibernateの方法はありますか?
はい、そのように見えますが、私の場合は動作しません。 \tプロパティhibernate.archive.autodetectionの定義は次のとおりです: ".parアーカイブを解析中にHibernate Entity Managerによってどの要素が自動検出されるかを判別する(デフォルトはclass、hbm)"。しかし、.parアーカイブとは何ですか?私はそのようなarhiveを聞いたことがない。 – 1tox
NB:元の投稿を更新しました – 1tox
.parアーカイブはエンティティとpersistence.xmlをバンドルできる永続アーカイブファイルです。それは必須ではないので、心配しないでください(Hibernateのチームメンバーからの最後の投稿を参照してください:https://forum.hibernate.org/viewtopic.php?f=9&t=947671)。別の提案は、 false exclude-unlisted-classes>を永続性ユニットに追加することです。 –
Cody