About a configuration parameter hibernate. hbm2ddl. Auto in hibernate

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.