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