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>
    	<property name="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</property> <!-- 数据库方言 -->
        <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property><!-- 引用jdbc包 -->
        <property name="hibernate.connection.username">root</property>
        <property name="hibernate.connection.password">123456</property>
        <property name="hibernate.connection.url">jdbc:mysql://127.0.0.1:3306/test?characterEncoding=UTF-8</property> <!-- 数据库链接 -->
        <property name="show_sql">true</property> <!-- true 执行完在控制台打印SQL语句 -->
        <property name="format_sql">false</property><!-- format_sql: 打印sql语句前,会将sql语句先格式化  -->
        <property name="hbm2ddl.auto">update</property>
        <!-- hibernate c3p0 -->
        <property name="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>
        <property name="hibernate.connection.autocommit">true</property> <!-- hibernate.connection.autocommit: 事务自动提交  -->
        <property name="hibernate.current_session_context_class">thread</property>   
            <!-- 表映射加载  -->
        <mapping resource="com/cn/user/User.hbm.xml"/>
<!--         <mapping class="com.cn.user.User"/> -->
    </session-factory>
   
</hibernate-configuration>

猜你喜欢

转载自blog.csdn.net/gdsgdh308227363/article/details/81629662