What are the possible values of the Hibernate hbm2ddl.auto configuration and what do they do

前端 未结 13 2424
轮回少年
轮回少年 2020-11-21 04:47

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 w

13条回答
  •  难免孤独
    2020-11-21 05:38

    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?

提交回复
热议问题