Does Hibernate create tables in the database automatically

后端 未结 8 1180
庸人自扰
庸人自扰 2020-12-01 07:23

Upon reading this (archived) tutorial, they have not mentioned anything over creating tables in the DB. Does the Hibernate handle it automatically by creating tables and fie

8条回答
  •  温柔的废话
    2020-12-01 08:02

    If property hibernate.ddl-auto = update, then it will not create the tables automatically. To create tables automatically, you need to set the property to hibernate.ddl-auto = create

    The list of option which is used in the spring boot 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 at the end of the session

    • none: is all other cases

    So for the first time you can set it to create and then next time on-wards you should set it to update.

提交回复
热议问题