Hibernate hbm2ddl.auto可能的值和他们做什么? [英] Hibernate hbm2ddl.auto possible values and what they do?
问题描述
我真的想知道更多关于更新,导出和可以赋予 hibernate.hbm2ddl.auto
的值。我需要知道何时使用更新,何时不使用?什么是替代品?
以上是可能发生在DB上的变化: b
$ b
在每种情况下,最好的解决方案是什么?
从社区文档:
创建会话工厂时hibernate.hbm2ddl.auto自动验证或出口模式DDL到数据库。使用create-drop,当SessionFactory被明确关闭时,数据库模式将被删除。
验证|更新|创建| create-drop
因此,可能的选项列表如下:
$ ul b $ b
这些选项似乎是开发人员工具,而不是为了方便任何生产级别的数据库,您可能需要查看以下问题; 休眠:在生产hbm2ddl.auto =更新
I really want to know more about the update, export and the values that could be given to hibernate.hbm2ddl.auto
I need to know when to use the update and when not? And what is the alternative?
These are changes that could happen over DB:
- New tables
- new columns in old tables
- columns deleted
- data type of a column changed
- a type of a column changed it attributes
- tables have been dropped
- values of a column has changed
In each case what is the best solution?
From the community documentation:
hibernate.hbm2ddl.auto Automatically validates or exports schema DDL to the database when the SessionFactory is created. With create-drop, the database schema will be dropped when the SessionFactory is closed explicitly.
e.g. validate | update | create | create-drop
So the list of possible options are,
- validate: validate the schema, makes no changes to the database.
- update: update the schema.
- create: creates the schema, destroying previous data.
- create-drop: drop the schema when the SessionFactory is closed explicitly, typically when the application is stopped.
These options seem intended to be developers tools and not to facilitate any production level databases, you may want to have a look at the following question; Hibernate: hbm2ddl.auto=update in production?
这篇关于Hibernate hbm2ddl.auto可能的值和他们做什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!