Hibernate automatically creates tables based on entity classes

Source: Internet
Author: User

Hibernate supports automatic table-building, which is convenient during the development phase and ensures automatic synchronization of HBM and database table structures.

How to use it? It's simple, just add the following code to the Hibernate.cfg.xml.

XML code <property name= "Hbm2ddl.auto" >update</property>

Update: Indicates that the table structure is automatically updated based on the model object, the database is automatically checked when Hibernate is started, and the table is automatically created if the table is missing, and columns are added automatically if columns are missing from the list.

There are other parameters as well:
Create: When you start Hibernate, the original table is automatically deleted and all the tables are created, so the previous data will be lost after each startup.

Create-drop: When you start hibernate, the table is automatically created and the corresponding table is automatically deleted when the program is closed. So at the end of the program, the table and the data no longer exist.

Hibernate automatically creates tables based on entity classes

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.