Hibernate核心配置文件cfg参数说明

逃离我推掉我的手 2022-06-07 02:08 312阅读 0赞
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE hibernate-configuration PUBLIC
  3. "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
  4. "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
  5. <hibernate-configuration>
  6. <session-factory>
  7. <!-- 1-设定Hibernate方言 : 相当于告诉Hibernate需要连接的数据库类型 -->
  8. <property name="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</property>
  9. <!-- 2-实现数据库连接 -->
  10. <property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
  11. <property name="hibernate.connection.password">tiger</property>
  12. <property name="hibernate.connection.url">jdbc:oracle:thin:@localhost:1521:orcl</property>
  13. <property name="hibernate.connection.username">scott</property>
  14. <!-- 3-想在Hibernate运行时,在控制台显示sql语句,并且对sql语句进行格式化 -->
  15. <property name="hibernate.show_sql">true</property>
  16. <property name="hibernate.format_sql">true</property>
  17. <!-- 4-设置Hibernate正向工程 根据JAVA代码和配置文件信息在数据库中创建表,更新数据
  18. update 没有表创建表,有表只更新
  19. create 每次执行都创建新表 -->
  20. <property name="hibernate.hbm2ddl.auto">update</property>
  21. <!-- 5-为了提高连接效率,应用c3p0数据库连接池 以下为相关配置 -->
  22. <property name="hibernate.c3p0.min_size">10</property>
  23. <property name="hibernate.c3p0.max_size">50</property>
  24. <property name="hibernate.c3p0.acquire_increment">10</property>
  25. <property name="hibernate.c3p0.max_statements">150</property>
  26. <!-- 作用:每隔2000ms检查一次连接池,如果发现某个连接没被使用炒作2S,则销毁该连接 -->
  27. <property name="hibernate.c3p0.timeout">2000</property>
  28. <property name="hibernate.c3p0.idle_test_period">2000</property>
  29. <!-- 可以使用SessionFactory的getCurrentSession方法 -->
  30. <property name="hibernate.current_session_context_class">thread</property>
  31. <!-- 当执行session.delete方法时,清空对象的oid -->
  32. <property name="hibernate.use_identifier_rollback">true</property>
  33. <!-- 提高sql存取性能 -->
  34. <property name="hibernate.jdbc.fetch_size">100</property>
  35. <property name="hibernate.jdbc.batch_size">30</property>
  36. <!-- 6-注册hbm组件(注意,使用/来表达路径) -->
  37. <mapping resource="com/hibernate/demo/Person.hbm.xml"/>
  38. </session-factory>
  39. </hibernate-configuration>

发表评论

表情:
评论列表 (有 0 条评论,312人围观)

还没有评论,来说两句吧...

相关阅读