Hibernate核心配置文件cfg参数说明
生活随笔
收集整理的這篇文章主要介紹了
Hibernate核心配置文件cfg参数说明
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
<?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>
《新程序員》:云原生和全面數字化實踐50位技術專家共同創作,文字、視頻、音頻交互閱讀
總結
以上是生活随笔為你收集整理的Hibernate核心配置文件cfg参数说明的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: JAVAWEB项目--模拟考试系统数据库
- 下一篇: Oracle PL/SQL小练习