The name of the 1:hibernate master configuration file must be hibernate.cfg.xml:
1.1: The main configuration file is divided into three main parts:
Note: Typically, a session-factory node represents a database;
1.1.1: The first part
Database connection section, note "Hibernate.connection.driver_class" in the middle of _ (bar);
1.1.2: Part Two
Other related configurations, including printing SQL statements, formatting SQL statements, creating data tables or updating data tables, etc.
1.1.3: Part III
load all the mappings;
1<! DOCTYPE hibernate-Configuration Public2"-//hibernate/hibernate Configuration DTD 3.0//en"3"Http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd" >4 56<!--Typically, a session-factory node represents a database--7<session-factory>8<!--(1): Data connection Configuration/(2): Load all Mappings (*.hbm.xml)--9 Ten<!--Part I: Data connection Configuration-- One<property name= "Hibernate.connection.driver_class" >com.mysql.jdbc.Driver</property> A<property name= "Hibernate.connection.url" >jdbc:mysql:///test</property> -<property name= "Hibernate.connection.username" >root</property> -<property name= "Hibernate.connection.password" >123456</property> the<!--Database Method configuration: The dialect of the MySQL database - hibernate generates SQL that conforms to the current database syntax in different dialects when it is running -- -<property name= "Hibernate.dialect" >org.hibernate.dialect.MySQLDialect</property> + -<!--Part II: Other Related Configurations-- +<!--2.1:hibernate.show_sql shows the SQL statement executed by hibernate runtime-- A<property name= "Hibernate.show_sql" >true</property> at<!--2.2: Formatted SQL-- -<property name= "Hibernate.format_sql" >true</property> -<!--2.3: auto-build Table-- -<property name= "Hibernate.hbm2ddl.auto" >create</property> -<!--<property name= "Hibernate.hbm2ddl.auto" >update</property> -- in<!-- - The table is executed each time the sessionfactory is created, and when the Close method of the sessionfactory is called, the tables are deleted to#hibernate. Hbm2ddl.auto create-Drop + re-build the table every time, delete and create if it already exists - #hibernate. Hbm2ddl.auto Create the If the table does not exist, it is created, and the table exists. * #hibernate. Hbm2ddl.auto Update $ perform validation when generating the environment, and error when the contents of the mapping file are different from the database table structurePanax Notoginseng #hibernate. Hbm2ddl.auto Validate -- the + A<!--Part III: Load all Mappings (*.hbm.xml)-- the<mapping resource= "Com/bie/po/user.hbm.xml"/> + -</session-factory> $Hibernate's core = = "Hibernate mapping, mastering the core technology, see in the next chapter."
Hibernate main configuration file Hibernate.cfg.xml