Hibernate Database Creation properties

Hibernate is a powerful open source java persistence framework. One of it’s feature is that it can automatically create your databases for you based on your code.
When you set the hibernate.hbm2dll.auto property, it allows you to either update, create, create-drop or validate your schema.

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

The legal 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.

Author: Dev

Full Stack Developer at one of the largest Banks in Canada.