【发布时间】:2018-07-04 01:49:09
【问题描述】:
我正在寻找用配置文件(也是存储库文件中的查询)替换 JPA 和休眠的注释(@Entity、@Table、@Id、@GenratedValue,...),但我没有知道该怎么做,我知道我需要另一个(除了 application.properties)XML 格式的配置文件,我的问题是我在哪里创建这个文件?它的内容是什么?
非常感谢您回复我。
现在我的项目如下所示: spring boot project
这是我的 orm.xml 文件:
<entity-mappings>
<entity class="org.sid.dao.entity.Etudiant">
<table name="etudiants">
<attributes>
<id name="id">
<genrated-value strategy="AUTO"></genrated-value>
</id>
<basic name="nom"></basic>
<basic name="prenom"></basic>
<many-to-one>
<Join-column name="id_formation">
<basic name="formation"></basic>
</Join-column>
</many-to-one>
</attributes>
</table>
</entity>
<entity class="org.sid.dao.entity.Formation">
<table name="formations">
<attributes>
<id name="id">
<genrated-value strategy="AUTO"></genrated-value>
</id>
<basic name="nom"></basic>
<basic name="duree"></basic>
<one-to-many mappedby="formation" fetch="lazy">
<basic name="etudiants"></basic>
</one-to-many>
</attributes>
</table>
</entity>
</entity-mappings>
但是JPA不会在数据库中创建表,我该怎么办?
【问题讨论】:
-
在已经使用 Spring Boot 的情况下为什么要这样做?
-
请不要这样做。
-
我只是想知道一个新的方法来做它,当我们将配置与看起来易于维护的类分开时,有人知道怎么做吗?
-
JPA 文档广泛可用,其中一些给出了注释的等效 XML 示例,例如 datanucleus.org:15080/products/accessplatform_5_1/jpa/…
标签: hibernate jpa spring-boot