hibernate常用配置hibernate.cfg.xml配置



<?xml version='1.0' encoding='utf-8'?>

<!DOCTYPE hibernate-configuration PUBLIC

“-//Hibernate/Hibernate Configuration DTD 3.0//EN”

“http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd" >

<hibernate-configuration>
    <session-factory>
        <!-- Database connection settings -->
        <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
        <property name="connection.url">jdbc:mysql://localhost:3306/uplooking1?

useUnicode=true&amp;characterEncoding=utf8

        </property>
        <property name="connection.username">root</property>
        <property name="connection.password"></property>

        <!-- JDBC connection pool (use the built-in) -->
        <property name="connection.pool_size">1</property>

        <property name="hibernate.cache.use_second_level_cache">true</property>

        <!--<property
name="cache.region.factory_class">org.hibernate.cache.ehcache.EhCacheRegionFactory</property>-->

        <!-- SQL dialect -->
       <property name="dialect">org.hibernate.dialect.MySQL5Dialect</property>

        <!-- Enable Hibernate's automatic session context management事物处理和当前线程绑定 -->
        <property name="current_session_context_class">thread</property>

        <!-- Echo回显 all executed SQL to stdout在控制台显示sql语句 -->
        <property name="show_sql">true</property>

        <!-- Drop and re-create the database schema on startup -->
        <property name="hbm2ddl.auto">update</property>

     <!--   <mapping class="Hibernate_onetomany_zhujie.Chapter"></mapping>
        <mapping class="Hibernate_onetomany_zhujie.Book"></mapping>-->
        <mapping resource="myhibernateDemo8/Publisher.hbm.xml"></mapping>
    </session-factory>
</hibernate-configuration>