Hibernate.cfg.xml全解

Hibernate.cfg.xml文件中的配置意义

相信初学的大家都和我一样,非常想搞清楚hibernate.cfg.xml文件中各种具体配置的意义,下面我把具体的内容描述一下

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
<!-- 可以有多组<session-factory>来配置多个数据库 -->
    <session-factory>
    <!-- 设置了hibernate连接数据库所需要的jdbc驱动类 -->
        <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
        <!-- 设置了hibernate连接数据库所使用的url -->
        <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/springdemo?useUnicode=true&amp;characterEncoding=UTF8&amp;autoReconnect=true</property>
        <!-- 设置了hibernate连接数据库所需要使用的用户名和密码 -->
        <property name="hibernate.connection.username">root</property>
        <property name="hibernate.connection.password"></property>
        <!-- 设置hibernat所使用的数据库方言类,该参数值根据数据库种类和版本有所不同 -->
        <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
        <!-- 设置是否显示实际操作数据库时的sql语句 -->
        <property name="hibernate.show_sql">true</property>
        <!-- 设置是否将显示的sql语句进行排版美化 -->
        <property name="hibernate.format_sql">true</property>
        <!-- hibernate配置ecache二级缓存 -->
        <property name="hibernate.cache.use_second_level_cache">true</property>
        <property name="hibernate.cache.use_query_cache">true</property>
        <property name="hibernate.cache.provider_configuration_file_resource_path">echache.xml</property>
        <property name="hibernate.cache.region.factory_class">org.hibernate.cache.ehcache.EhCacheRegionFactory</property>
        <property name="hibernate.generate_statistics">true</property>
        <!-- 设置hibernate所映射出来的类 -->
        <mapping class="com.telek.model.User"/>
        <mapping class="com.telek.model.Address"/>
        <mapping class="com.telek.model.Topic"/>
        <mapping class="com.telek.model.Tag"/>
    </session-factory>
</hibernate-configuration>

本文将随着本人的学习进度持续更新

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值