瘋狂

          STANDING ON THE SHOULDERS OF GIANTS
          posts - 481, comments - 486, trackbacks - 0, articles - 1
            BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理
          hibernate默認(rèn)情況:
          <property name="connection.release_mode">auto</property>--釋放jdbc resources 方式 如果不配置默認(rèn)是auto (當(dāng)然現(xiàn)在沒有auto了,等同于"after_statement" or "after_transaction"),注意3.0以及之前默認(rèn)是ON_CLOSE(也就是session關(guān)閉才釋放jdbc鏈接)
          <property name="transaction.auto_close_session">false</property>--自動(dòng)關(guān)閉session
          <property name="connection.autocommit">false</property>--自動(dòng)提交
          release_mode的設(shè)置見于:http://www.aygfsteel.com/freeman1984/archive/2011/07/27/355110.html
          1 首先connection.autocommit配置成false的情況:
               此種情況需要手動(dòng)開啟事務(wù),需要手動(dòng)開啟transaction,以及提交transaction,并且此時(shí)transaction.auto_close_session配置的配置將自動(dòng)設(shè)置為false,所以此時(shí)如果connection.release_mode配置為on_close()時(shí)需要手動(dòng)關(guān)閉session才能釋放JDBC 連接,日志會(huì)提示:
           transaction completed on session with on_close connection release mode; be sure to close the session to release JDBC resources!
          因此connection.autocommit為false的情況建議connection.release_mode采取默認(rèn)auto。

          2 connection.autocommit為true的情況,此時(shí)不需要手動(dòng)開啟transaction以及提交transaction,hibernate自動(dòng)開始transaction并在每次操作后提交transaction,設(shè)置此   時(shí)transaction.auto_close_session設(shè)置將自動(dòng)為false。 如果connection.release_mode配置為on_close()是需要手動(dòng)關(guān)閉session才能釋放JDBC 連接.建議此種情況connection.release_mode設(shè)置默認(rèn)auto。

          3 connection.autocommit為true的情況,如果此時(shí)又手動(dòng)開啟了transaction,此時(shí)connection.autocommit將被設(shè)置為false(disabling autocommit),需要手動(dòng)提交transaction,此種情況如同第一種情況。
           
          有問題請(qǐng)補(bǔ)充。tks
          主站蜘蛛池模板: 新沂市| 张北县| 河间市| 天峨县| 什邡市| 贵定县| 文成县| 维西| 金湖县| 扬州市| 巴马| 馆陶县| 全南县| 永顺县| 中牟县| 柳江县| 长垣县| 黄石市| 辉县市| 安庆市| 明溪县| 介休市| 门源| 靖边县| 应城市| 新巴尔虎右旗| 靖州| 蓬莱市| 桃园县| 高陵县| 德兴市| 玉门市| 武宁县| 墨玉县| 新野县| 灵山县| 资中县| 宁蒗| 云和县| 渝中区| 于田县|