休眠 - hibernate.hbm2ddl.auto = 验证 [英] Hibernate - hibernate.hbm2ddl.auto = validate

查看:23
本文介绍了休眠 - hibernate.hbm2ddl.auto = 验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对 hibernate.hbm2ddl.auto=validate 的实际工作原理很感兴趣,我正在努力寻找全面的文档.

I am interested in how hibernate.hbm2ddl.auto=validate actually works and I am struggling to find comprehensive documentation.

我们最近发现生产系统受到 http://opensource 的影响.atlassian.com/projects/hibernate/browse/HHH-3532(Hibernate 匹配名称上的外键,而不是签名,因此将为您重新创建它们)并且 hibernate.hbm2ddl.auto=update 将从我们的下一个中删除发布.

We've recently discovered production system was affected by http://opensource.atlassian.com/projects/hibernate/browse/HHH-3532 (Hibernate matches foreign keys on name, rather than signature and so will recreate them for you) and hibernate.hbm2ddl.auto=update is being removed from our next release.

我很乐意完全摆脱 hibernate.hbm2ddl.auto 并自己管理我们的数据库.然而,并非我的所有同事都认同这种世界观,有些人热衷于在 hibernate.hbm2ddl.auto=validate 中添加.

I would be quite happy to just get rid of hibernate.hbm2ddl.auto altogether and manage our database ourselves. However, not all my colleagues share this world view and some are keen to add back in hibernate.hbm2ddl.auto=validate.

我担心这会遇到同样的问题,我有兴趣找到更多有关此验证实际工作方式的文档.Hibernate 社区文档(http://docs.jboss.org/hibernate/core/3.3/reference/en/html/session-configuration.html) 实际上只是参考了这些值.

I'm concerned this will hit the same problem and I'm interested in finding more documentation about how this validation actually works. The Hibernate Community Documentation (http://docs.jboss.org/hibernate/core/3.3/reference/en/html/session-configuration.html) really just makes reference to the values.

有没有人有任何好的文档指针,或者任何在生产系统中使用验证的实际经验?

Does anyone have any good documentation pointers, or any real life experience of using validate in a production system?

推荐答案

我担心这会遇到同样的问题,我有兴趣找到更多有关此验证实际工作原理的文档.

I'm concerned this will hit the same problem and I'm interested in finding more documentation about how this validation actually works.

在我看来,最好的文档是源代码,您可以检查它以了解究竟发生了什么.相关方法是org.hibernate.tool.hbm2ddl.SchemaValidator#validate().

In my opinion, the best documentation is the source code that you could check to see what is happening exactly. The relevant method is org.hibernate.tool.hbm2ddl.SchemaValidator#validate().

我快速浏览了代码,认为 SchemaValidator 不会验证数据库中的外键:它会检查是否存在表、列、id 生成器但不是外键.针对宠物数据库的测试似乎证实了这种行为:删除 FK 约束不会破坏架构验证(换句话说,验证器检查应用程序是否可以运行,而不是为了参照完整性).

I went quickly through the code and I don't think that the SchemaValidator verifies foreign keys in the database: it checks the presence of tables, columns, id generators but not foreign keys. A test against a pet database seems to confirm this behavior: dropping a FK constraint doesn't break schema validation (in other words, the validator checks if the application can run, not for referential integrity).

现在,HHH-3532 被标记为已修复,为什么不升级到更新版本的 Hibernate 或者,如果更改 Hibernate 版本太重,为什么不应用 HHH-3532 自己?

Now, HHH-3532 being marked as fixed, why don't you upgrade to a newer version of Hibernate or, if changing the version of Hibernate is too heavy, why don't you apply the patch for HHH-3532 yourself?

话虽如此,不使用 hibernate.hbm2ddl.auto=update 来更新生产数据库,我使用更改脚本.但是使用 hibernate.hbm2ddl.auto=validate 并且我很满意.

Having that all said, I don't use hibernate.hbm2ddl.auto=update to update production databases, I use change scripts. But I use hibernate.hbm2ddl.auto=validate and I'm happy with it.

这篇关于休眠 - hibernate.hbm2ddl.auto = 验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆