Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
297 views
in Technique[技术] by (71.8m points)

java - Hibernate hbm2ddl.auto配置的可能值是什么,它们做了什么(What are the possible values of the Hibernate hbm2ddl.auto configuration and what do they do)

I really want to know more about the update, export and the values that could be given to hibernate.hbm2ddl.auto

(我真的想知道更多关于更新,导出和可以给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:

(这些是可能发生在DB上的变化:)

  • new tables

    (新表)

  • new columns in old tables

    (旧表中的新列)

  • columns deleted

    (列已删除)

  • data type of a column changed

    (列的数据类型已更改)

  • a type of a column changed its attributes

    (列的类型更改了其属性)

  • tables dropped

    (桌子掉了)

  • values of a column changed

    (列的值已更改)

In each case what is the best solution?

(在每种情况下,最佳解决方案是什么?)

  ask by translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

From the community documentation :

(来自社区文档 :)

hibernate.hbm2ddl.auto Automatically validates or exports schema DDL to the database when the SessionFactory is created.

(hibernate.hbm2ddl.auto创建SessionFactory时,自动验证或将架构DDL导出到数据库。)

With create-drop, the database schema will be dropped when the SessionFactory is closed explicitly.

(使用create-drop,当SessionFactory显式关闭时,将删除数据库模式。)

eg validate |

(例如验证|)

update |

(更新|)

create |

(创建|)

create-drop

(创建降)

So the list of possible options are,

(所以可能的选项列表是,)

  • validate : validate the schema, makes no changes to the database.

    (validate :验证模式,不对数据库进行任何更改。)

  • update : update the schema.

    (更新 :更新架构。)

  • create : creates the schema, destroying previous data.

    (create :创建架构,销毁以前的数据。)

  • create-drop : drop the schema when the SessionFactory is closed explicitly, typically when the application is stopped.

    (create-drop :显式关闭SessionFactory时删除模式,通常是在应用程序停止时。)

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 =在生产中更新?)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...