Hibernate-----core configuration file, mapping file

1. Core configuration file

There are two ways to configure:









The following are the specific applications of the above three optional configurations:

1.1 Console Printing

Generally, when writing programs, most of them are mainly used to test whether the sql statement is generated normally.

In order to display sql more clearly, formatted display can be used.




1.2 Integrate C3P0 connection pool

Instead of using the default hibernate connection pool, set it yourself.




1.3 Automatically create tables

This property has 4 parameters.




Generally used for testing;



create is basically not used;


So generally used is update.

If you make changes to the javabean, add an attribute, but the attribute does not exist in the table column. After you set update, run it.

A newly set column will automatically appear in the database table.

If you modify some structure of the table, when you run inconsistent, it will automatically modify the table.

Note: He will check whether the structure of the table and the class is consistent, and if it is inconsistent, the structure of the table will be updated. instead of updating our javabeans.


validate: It is used to verify whether the database table and javabean are consistent, and an error will be reported if they are inconsistent. As shown.



2 Configuration file (.hbm.xml)

There are mainly 3 fields: class, id, column,









Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326635286&siteId=291194637