hibernate.cfg.xml文件详解

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

<!DOCTYPEhibernate-configurationPUBLIC

"-//Hibernate/HibernateConfigurationDTD3.0//EN"

        "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">  

<hibernate-configuration>  

    <session-factory>  

        <!--  数据库连接设置 -->

<propertyname="connection.driver_class">com.mysql.jdbc.Driver</property>

<propertyname="connection.url">jdbc:mysql://localhost/hibernate</property>

<propertyname="connection.username">root</property>

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

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

        <!-- SQL dialect 方言 -->      

<propertyname="dialect">org.hibernate.dialect.MySQLDialect</property>

<!--EnableHibernate'sautomaticsessioncontextmanagement-->

        <!-- <property name="current_session_context_class">thread</property>-->  

        <!-- Disable the second-level cache 2级缓存 -->        <property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>  

        <!--    show_sql   生成sql语句 -->

<propertyname="show_sql">true</property>

<!--format_sql生成更漂亮的sql语句-->

        <property name="format_sql">true</property>  

        <!-- 取值 validate | update | create | create-drop  -->        <property name="hbm2ddl.auto">create</property>    

        <!-- 添加实体类的映射文件  -->

<mappingresource="com/cfeers/hibernate/model/Student.hbm.xml"/>

<!--Annotation方式配置-->

<mappingclass="com.cfeers.hibernate.model.Teacher"/>

    </session-factory>  

</hibernate-configuration>

相关推荐