hibernate配置文件

<?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>
<property name="hibernate.connection.driver_class">com.microsoft.sqlserver.jdbc.SQLServerDriver</property> <!-- 数据库驱动 -->
<property name="hibernate.connection.url">jdbc:sqlserver://192.168.0.47:1433;databaseName=ZJBQ</property> <!-- ip 端口 数据库名称 -->
<property name="hibernate.connection.username">sa</property> <!-- 数据库用户名 -->
<property name="hibernate.connection.password">123456</property> <!-- 数据库密码 -->
<property name="hibernate.connection.pool.size">20</property> <!-- 数据库连接池大小 -->
<property name="hibernate.show_sql">true </property> <!--后台显示Hibernate用到的SQL语句,开发时设置为true,便于差错,项目部署后可以设置为false -->
<property name="jdbc.fetch_size">50 </property> <!-- Hibernate每次从数据库中取出并放到JDBC的Statement中的记录条数。Fetch Size设的越大,读数据库的次数越少,速度越快,Fetch
Size越小,读数据库的次数越多,速度越慢 -->
<property name="jdbc.batch_size">23 </property> <!--Hibernate批量插入,删除和更新时每次操作的记录数。Batch Size越大,批量操作的向数据库发送Sql的次数越少,速度就越快,同样耗用内存就越大 -->
<property name="jdbc.use_scrollable_resultset">false </property> <!--是否允许Hibernate用JDBC的可滚动的结果集。对分页的结果集。对分页时的设置非常有帮助 -->
<property name="Connection.useUnicode">true </property> <!--连接数据库时是否使用Unicode编码 -->
<property name="connection.characterEncoding">gbk </property> <!-- 连接数据库时数据的传输字符集编码方式 -->
<property name="hibernate.dialect">org.hibernate.dialect.SQLServer2008Dialect </property> <!--数据库方言配置 -->
<!-- <property name="hibernate.dialect">org.hibernate.dialect.SQLServer2005Dialect
</property> <property name="hibernate.dialect">org.hibernate.dialect.SQLServer2000Dialect
</property> <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect
</property> -->

<mapping resource="hibernate/first/Users.hbm.xml" /> <!-- 注册实体类对应的配置文件 -->
</session-factory>

</hibernate-configuration>

原文地址:https://www.cnblogs.com/Zhong-Xin/p/6392476.html