<?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>
<!-- 1-设定Hibernate方言 : 相当于告诉Hibernate需要连接的数据库类型 -->
<property name="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</property>
<!-- 2-实现数据库连接 -->
<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="hibernate.connection.password">tiger</property>
<property name="hibernate.connection.url">jdbc:oracle:thin:@localhost:1521:orcl</property>
<property name="hibernate.connection.username">scott</property>
<!-- 3-想在Hibernate运行时,在控制台显示sql语句,并且对sql语句进行格式化 -->
<property name="hibernate.show_sql">true</property>
<property name="hibernate.format_sql">true</property>
<!-- 4-设置Hibernate正向工程 根据JAVA代码和配置文件信息在数据库中创建表,更新数据
update 没有表创建表,有表只更新
create 每次执行都创建新表 -->
<property name="hibernate.hbm2ddl.auto">update</property>
<!-- 5-为了提高连接效率,应用c3p0数据库连接池 以下为相关配置 -->
<property name="hibernate.c3p0.min_size">10</property>
<property name="hibernate.c3p0.max_size">50</property>
<property name="hibernate.c3p0.acquire_increment">10</property>
<property name="hibernate.c3p0.max_statements">150</property>
<!-- 作用:每隔2000ms检查一次连接池,如果发现某个连接没被使用炒作2S,则销毁该连接 -->
<property name="hibernate.c3p0.timeout">2000</property>
<property name="hibernate.c3p0.idle_test_period">2000</property>
<!-- 可以使用SessionFactory的getCurrentSession方法 -->
<property name="hibernate.current_session_context_class">thread</property>
<!-- 当执行session.delete方法时,清空对象的oid -->
<property name="hibernate.use_identifier_rollback">true</property>
<!-- 提高sql存取性能 -->
<property name="hibernate.jdbc.fetch_size">100</property>
<property name="hibernate.jdbc.batch_size">30</property>
<!-- 6-注册hbm组件(注意,使用/来表达路径) -->
<mapping resource="com/hibernate/demo/Person.hbm.xml"/>
</session-factory>
</hibernate-configuration>
还没有评论,来说两句吧...