Hibernate auto create database

后端 未结 4 1582
花落未央
花落未央 2020-12-02 20:19

I have a Java EE Hibernate project, and I\'m using MySQL as a database.

I want that when I first time run the project, it will create the database automatically.

4条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-02 21:10

    There are multiple option for auto property.

    1. create - It creates new tables corresponding mapping or annotation. It drops existing tables and data.
    2. update - It keeps existing data and tables. It updates schema. here we have to take care contrants.
    3. create-drop - It is same like create but once session gets closed it drops everything.
    4. validate - it validates or matches schema with map or annotation. It's valid for Production environment.

      
      update
      

    I hope it helps.

提交回复
热议问题