Core configuration Files
<!--Sessionfactory, equivalent to learning the connection pool configuration before - <session-factory> <!--1 Basic 4 Items - < Propertyname= "Hibernate.connection.driver_class">Com.mysql.jdbc.Driver</ Property> < Propertyname= "Hibernate.connection.url">jdbc:mysql:///h_day01_db</ Property> < Propertyname= "Hibernate.connection.username">Root</ Property> < Propertyname= "Hibernate.connection.password">1234</ Property> <!--2 binding with local thread - < Propertyname= "Hibernate.current_session_context_class">Thread</ Property> <!--3 dialect: for different databases, different versions, generate SQL statements (DQL query statements) to provide basis * MySQL string varchar * Orcale string VARCHAR2
- < Propertyname= "Hibernate.dialect">Org.hibernate.dialect.MySQL5Dialect</ Property> <!--4 SQL statements - <!--Displaying SQL statements - < Propertyname= "Hibernate.show_sql">True</ Property> < Propertyname= "Hibernate.format_sql">True</ Property> <!--5 Automatically create tables (learn), use in learning, develop unused. * The DBA first creates the table, and then the PO class * is evaluated according to the table: Update: "" If the table does not exist, the table will be created. If the table already exists, update the table (add) through the HBM mapping file. (The mapping file must be a database counterpart) the columns in the table can be many and are not responsible for deletion. Create: If the table exists, delete it before creating it. The previously created table is not deleted at the end of the program. "Create-drop: Almost the same as create. If Factory.close () executes, the created table will be deleted while the JVM shuts down. (test) Validate: Verifies that the HBM mapping file and the column of the table correspond, if the corresponding normal execution, if not the exception should be thrown. (test) - < Propertyname= "Hibernate.hbm2ddl.auto">Create</ Property> <!--6 Java Web 6.0 holds a problem * beanfactory NULL pointer exception exception hint: Org.hibernate.HibernateException:Unable to Get the default Bean Validation Factory * Solution: Cancel Bean checksum - < Propertyname= "Javax.persistence.validation.mode">None</ Property> <!--Add Map File <mapping > Add mapping File resource set XML configuration file (AddResource (XML)) class The Configuration Class (AddClass (User.class)) is configured with a fully qualified class name - <MappingResource= "Com/itheima/a_hello/user.hbm.xml"/> </session-factory>
Hibernate's core configuration file