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

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

问题描述

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



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



我会很高兴地完全摆脱hibernate.hbm2ddl.auto并自己管理我们的数据库。然而,并不是所有的同事都会分享这个世界观,有些人热衷于在hibernate.hbm2ddl.auto = validate中加入。



我担心这会造成同样的结果问题,我有兴趣找到更多有关这种验证实际工作的文档。 Hibernate社区文档( http:// docs。 jboss.org/hibernate/core/3.3/reference/en/html/session-configuration.html )真的只是引用了这些值。



确实任何人都有任何良好的文档指针,或在生产系统中使用验证的真实生活经验?

解决方案


<




我担心这样做会遇到同样的问题,我有兴趣找到更多有关此验证实际工作方式的文档。 >在我看来,最好的文档是可以检查确切发生了什么的源代码。相关的方法是 org.hibernate.tool.hbm2ddl.SchemaValidator#validate()



代码和 I 不认为 SchemaValidator 验证数据库中的外键 :它检查是否存在表,列,id生成器但不包含外键。对宠物数据库的测试似乎证实了这种行为:删除FK约束不会中断模式验证(换言之,验证程序将检查应用程序是否可以运行,而不是用于参照完整性)。



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

说了这么多话, 没有使用 hibernate.hbm2ddl.auto = update 更新生产数据库,我使用更改脚本。但 使用 hibernate.hbm2ddl.auto = validate ,我很满意。


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

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.

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.

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.

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().

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).

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?

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 - hibernate.hbm2ddl.auto =验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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