How to create database schema in hibernate first time and further update it in case of schema modification?

前端 未结 3 1005
余生分开走
余生分开走 2020-11-30 11:05

I want to create database schema in hibernate first time. And further, if there is any modification in the schema, like addition of a new table or deletion of some column, I

3条回答
  •  南笙
    南笙 (楼主)
    2020-11-30 12:00

    You can use 'import.sql' .

    Add a import.sql file in resource as follow:

    /*create database at first time*/ 
    CREATE SCHEMA your-database-name;
    

    and add a line in 'hibernate.cfg.xml' as follow:

    
        
           ...
           ...
           import.sql
           ...
           ...
        
    
    

    So, if not exist the database, hibernate creates new db.

提交回复
热议问题