本文翻译自:Hibernate: hbm2ddl.auto=update in production?

是否可以运行使用hbm2ddl.auto=update配置的Hibernate应用程序来更新生产环境中的数据库模式?


#1楼

参考:https://stackoom.com/question/vad/Hibernate-hbm-ddl-auto-在生产中更新


#2楼

  • Typically enterprise applications in large organizations run with reduced privileges. 通常,大型组织中的企业应用程序以较低权限运行

  • Database username may not have DDL privilege for adding columns which hbm2ddl.auto=update requires. 数据库用户名可能没有DDL权限来添加hbm2ddl.auto=update所需的列。


#3楼

Hibernate has to put the disclaimer about not using auto updates in prod to cover themselves when people who don't know what they are doing use it in situations where it should not be used. Hibernate必须放弃关于不使用自动更新的免责声明,以便当不知道他们正在做什么的人在不应该使用它的情况下使用它时自己覆盖。

Granted the situations where it should not be used greatly outnumber the ones where it's OK. 在不应该使用的情况下,可以大大超过那些可以使用的情况。

I have used it for years on lots of different projects and have never had a single issue. 我已经在很多不同的项目上使用它多年,从来没有遇到过一个问题。 That's not a lame answer, and it's not cowboy coding. 这不是一个蹩脚的答案,而不是牛仔编码。 It's a historic fact. 这是一个历史事实。

A person who says "never do it in production" is thinking of a specific set of production deployments, namely the ones he is familiar with (his company, his industry, etc). 一个说“从不在生产中做”的人正在考虑一组特定的生产部署,即他熟悉的(他的公司,他的行业等)。

The universe of "production deployments" is vast and varied. “生产部署”的范围广泛而多样。

An experienced Hibernate developer knows exactly what DDL is going to result from a given mapping configuration. 经验丰富的Hibernate开发人员确切知道DDL将从给定的映射配置中产生什么。 As long as you test and validate that what you expect ends up in the DDL (in dev, qa, staging, etc), you are fine. 只要你测试并验证你期望在DDL中的内容(在dev,qa,staging等中),你就可以了。

When you are adding lots of features, auto schema updates can be a real time saver. 当您添加许多功能时,自动架构更新可以节省大量时间。

The list of stuff auto updates won't handle is endless, but some examples are data migration, adding non-nullable columns, column name changes, etc, etc. 自动更新无法处理的内容列表是无穷无尽的,但一些示例是数据迁移,添加不可为空的列,列名称更改等。

Also you need to take care in clustered environments. 您还需要在群集环境中小心。

But then again, if you knew all this stuff, you wouldn't be asking this question. 但话说回来,如果你知道所有这些东西,你就不会问这个问题了。 Hmm . 嗯。 . . OK, if you are asking this question, you should wait until you have lots of experience with Hibernate and auto schema updates before you think about using it in prod. 好吧,如果你问这个问题,你应该等到你有很多Hibernate和自动架构更新的经验,然后才考虑在prod中使用它。


#4楼

  • In my case (Hibernate 3.5.2, Postgresql, Ubuntu), setting hibernate.hbm2ddl.auto=update only created new tables and created new columns in already existing tables. 在我的例子中(Hibernate 3.5.2,Postgresql,Ubuntu),设置hibernate.hbm2ddl.auto=update只创建新表并在现有表中创建新列。

  • It did neither drop tables, nor drop columns, nor alter columns. 它既没有删除表,也没有删除列,也没有改变列。 It can be called a safe option, but something like hibernate.hbm2ddl.auto=create_tables add_columns would be more clear. 它可以被称为安全选项,但像hibernate.hbm2ddl.auto=create_tables add_columns这样的东西会更清楚。


#5楼

No, it's unsafe. 不,这不安全。

Despite the best efforts of the Hibernate team, you simply cannot rely on automatic updates in production . 尽管Hibernate团队做出了最大努力,但您根本无法依靠生产中的自动更新。 Write your own patches, review them with DBA, test them, then apply them manually. 编写自己的补丁,使用DBA进行检查,测试它们,然后手动应用它们。

Theoretically, if hbm2ddl update worked in development, it should work in production too. 从理论上讲,如果hbm2ddl update在开发中有效,它也应该在生产中工作。 But in reality, it's not always the case. 但实际上,并非总是如此。

Even if it worked OK, it may be sub-optimal. 即使它工作正常,也可能是次优的。 DBAs are paid that much for a reason. DBA因为某种原因得到了很多报酬。


#6楼

I wouldn't risk it because you might end up losing data that should have been preserved. 我不会冒险,因为你最终可能会丢失应该保留的数据。 hbm2ddl.auto=update is purely an easy way to keep your dev database up to date. hbm2ddl.auto = update纯粹是一种让您的dev数据库保持最新的简单方法。

Hibernate:hbm2ddl.auto =在生产中更新?相关推荐

  1. Hibernate hbm2ddl.auto配置的可能值是什么,它们做了什么

    本文翻译自:What are the possible values of the Hibernate hbm2ddl.auto configuration and what do they do I ...

  2. hibernate.hbm2ddl.auto的value

    Hibernate 配置参数hibernate.hbm2ddl.auto Hibernate中的配置文件: <properties> <property name="hib ...

  3. hibernate hbm2ddl.auto 问题

    为什么80%的码农都做不了架构师?>>>    <property name="hibernate.show_sql" value="true&q ...

  4. hibernate.hbm2ddl.auto配置详解

    hibernate.hbm2ddl.auto配置详解 http://www.cnblogs.com/feilong3540717/archive/2011/12/19/2293038.html hib ...

  5. hibernate.hbm2ddl.auto配置及意义

    *********************************************************** 这两天在整理Spring + JPA(Hibernate实现),从网上copy了 ...

  6. hibernate中hibernate.hbm2ddl.auto配置讲解

    2019独角兽企业重金招聘Python工程师标准>>> 介绍其中的一个属性hbm2ddl.auto,这个就是这个方案的核心属性,有四个值:create,create-drop,upd ...

  7. Nhibernate.hbm2ddl.auto配置详解

    hibernate.cfg.xml 中hibernate.hbm2ddl.auto配置节点如下: <properties> <property name="hibernat ...

  8. hibenate.hbm2ddl.auto属性详解

    hibernate配置属性中,hibernate.hbm2ddl.auto可以帮助你实现正向工程,即由java代码生成数据库脚本,进而生成具体的表结构.      在hibernate.cfg.xml ...

  9. 在生产中使用Java 11:需要了解的重要事项

    来源:SpringForAll社区 如果您正考虑更新最新版本的Java,阅读本文以了解有关Oracle Java 11的最重要信息. 如果您及时了解Java社区的新闻,您可能听说Oracle改变了他们 ...

最新文章

  1. Nginx配置文件nginx.conf中文详解(总结)
  2. android开发环境建立以及开发工具的使用--怎样使用eclipse来开发android源码
  3. pycharm用爱发电
  4. Bootstrap整合ASP.NET MVC验证、jquery.validate.unobtrusive
  5. ASP.NET MVC (三、表单与文件上传)
  6. [Java网络编程基础]端口,协议
  7. 20 张图揭开内存管理的迷雾,瞬间豁然开朗
  8. 射频测试系统软件,新的~~蓝牙5.0射频测试系统
  9. ABAP中的枚举对象
  10. 【电子技术实验理论】语音放大电路
  11. FPGA verilog 临近插值任意比例视频缩放代码
  12. 再谈js拖拽(二)仿iGoogle自定义首页模块拖拽
  13. SSL/TLS 受诫礼攻击漏洞的问题的解决记录
  14. 深度学习跑项目的注意事项
  15. 【深度之眼】【百面机器学习】决策树
  16. ISME | 浙大黄健华/陈学新等揭示寄生蜂调控寄主营养代谢的新机制
  17. vim的下载安装与基本使用
  18. zip压缩包密码解密
  19. 中国基金业协会网站资产管理业务综合报送平台-数据爬取
  20. 【Python】函数相关

热门文章

  1. 内存分配策略(二):JMM,Java Memory Model
  2. Android Hook ActivityThread mH 消息
  3. Mysql数据库事务详解
  4. python断点调试不起作用flask_关于python的flask框架下的调试
  5. Android之EasyPermissions源码解析
  6. 常用服务器返回码意义
  7. python web框架介绍对比
  8. (03) spring Boot 的配置
  9. 清北学堂模拟赛d5t4 套路
  10. Hibernate一对多(注解)