使用 Hibernate-tools 更新架构

发布于 2024-12-25 16:48:28 字数 622 浏览 2 评论 0原文

我当前正在使用 EclipseLink JPA,并且在我的 persistence.xml 文件中设置了此属性。

<property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>

当前设置为在每次运行时删除和创建表的 value 字段导致我的测试数据被删除。不幸的是,EclipseLink 不支持与我的项目中实体的任何更改集成的 update 模式属性。我在某处读到,Hibernate-tools 可以用来更新数据库架构而不删除当前记录?

我已经尝试过这个属性,

 <property name="eclipselink.ddl-generation" value="create-tables"/>

虽然它确实保留了我的数据,但它不会更新表架构。

在我的 persistence.xml 中我可以包含 hibernate 属性吗?

 property name="hibernate.hbm2ddl.auto" value="update"

I am currently using EclipseLink JPA and in my persistence.xml file i have this property set

<property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>

The value field currently set to drop and create tables on each run is causing my test data to be deleted. Unfortunately, EclipseLink does not support an update schema property that integrates with any changes to Entities in my project. I read somewhere, Hibernate-tools can be used to update the database schema without deleting current records?

I have tried this property

 <property name="eclipselink.ddl-generation" value="create-tables"/>

while it does keep my data, it doesn't update table schema.

In my persistence.xml can i include the hibernate property ?

 property name="hibernate.hbm2ddl.auto" value="update"

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

骷髅 2025-01-01 16:48:28

EclipseLink(从 2.3.2 开始)不支持通过 DDL 更改现有表来添加缺失的字段。请参阅功能请求 https://bugs.eclipse.org/bugs/show_bug.cgi ?id=368365

EclipseLink (as of 2.3.2) doesn't support DDL altering existing tables to add missing fields. Please see feature request https://bugs.eclipse.org/bugs/show_bug.cgi?id=368365

终止放荡 2025-01-01 16:48:28

不,您只能使用标准 jpa 属性或持久性提供程序的属性(在您的情况下为 EclipseLink)。我相信在这里您会找到答案。

No, you can use only standart jpa properties or properties of your persistence provider (EclipseLink in your case). I believe that here you will find your answer.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文