In the past two days, spring + JPA (hibernate implementation) has been compiled and a piece of hibernate connection parameter configuration has been copied from the Internet.
< Properties >
< Property Name = "Hibernate. show_ SQL" Value = "True" />
< Property Name = "Hibernate. hbm2ddl. Auto" Value = "CREATE" />
</ Properties >
Results During the test, data in the database table is always lost. This parameter was not used much before. I checked other items in a circle and finally located it. Check the parameter configuration of hibernate as follows:
Hibernate. hbm2ddl. auto automatically validate or export 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. eg. validate | update | create-drop
In fact, this parameter is mainly used to: automatically create | update | verify the database table structure. If not, we recommend that you set value = "NONE ".
The meanings of other parameters are explained as follows:
Verify the structure of the created database table when loading hibernate in validate.
Create loads hibernate each time and re-creates the database table structure, which is the cause of data loss in the database table.
Create-drop is created when Hibernate is loaded. Exit is to delete the table structure
Update load hibernate automatically updates the database structure
Summary:
1. Use this parameter with caution. Do not use this parameter unless necessary.
2. If the database table is lost, check the configuration of hibernate. hbm2ddl. Auto.