<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<!--此处使用的是mysql数据库,配置如下-->
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/hibernate</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">111111</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<!--此处使用的是sqlServer数据库,配置如下-->
<property name="connection.driver_class">com.microsoft.sqlserver.jdbc.SQLServerDriver</property>
<property name="connection.url">jdbc:sqlserver://localhost:1433;databaseName=hibernate;</property>
<property name="connection.username">root</property>
<property name="connection.password">111111</property>
<property name="dialect">org.hibernate.dialect.SQLServerDialect</property>
<property name="hibernate.hbm2ddl.auto">create</property>
<property name="hibernate.show_sql">true</property>
<property name="hibernate.cache.use_second_level_cache">true</property>
<property name="hibernate.cache.provider_class">org.hibernate.cache.OSCacheProvider</property>
<!--此处是配置二级缓存,这里注释掉是因为在映射文件中配置了-->
<!--
<class-cache usage="read-only" class="com.xyls.hibernate.po.User"/>
-->
<property name="hibernate.generate_statistics">true</property>
<!--此处设置允许查询也使用二级缓存,hibernate中查询默认不开启-->
<property name="hibernate.cache.use_query_cache">true</property>
<mapping resource="com/xyls/hibernate/po/User.hbm.xml"/>
</session-factory>
</hibernate-configuration>