Hibernate hbm2ddl.auto 配置的可能值是什么,它们的作用是什么 [英] What are the possible values of the Hibernate hbm2ddl.auto configuration and what do they do

查看:48
本文介绍了Hibernate 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 its attributes
  • tables dropped
  • values of a column 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.
  • none: does nothing with the schema, makes no changes to the database

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屋!

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