锘??xml version="1.0" encoding="utf-8" standalone="yes"?>国产AV无码专区亚洲AV蜜芽,亚洲av无码精品网站,亚洲天堂电影在线观看http://www.tkk7.com/jesson2005/category/19579.html鍚鵑潪鏂囦漢錛屼箖甯備簳涓淇椾漢涔燂紝璇葷櫨鍗蜂功錛岃法姹熸渤鍗冮噷錛屾晠鐢沖煄涓娓革紱 涓涓ゆ淮杈涢吀錛屼笁鍥涘勾瀛︿笟錛屼簲鍏偣綺楀ⅷ錛屼竷鍏瑪涔板崠錛屼節鍗侀亾浜烘儏銆?/description>zh-cnThu, 17 May 2007 03:34:15 GMTThu, 17 May 2007 03:34:15 GMT60Hibernate浜嬪姟綆$悊 http://www.tkk7.com/jesson2005/articles/113524.html寮犻噾楣?/dc:creator>寮犻噾楣?/author>Wed, 25 Apr 2007 06:16:00 GMThttp://www.tkk7.com/jesson2005/articles/113524.htmlhttp://www.tkk7.com/jesson2005/comments/113524.htmlhttp://www.tkk7.com/jesson2005/articles/113524.html#Feedback0http://www.tkk7.com/jesson2005/comments/commentRss/113524.htmlhttp://www.tkk7.com/jesson2005/services/trackbacks/113524.htmlHibernate浜嬪姟綆$悊
  Hibernate鏄疛DBC鐨勮交閲忕駭灝佽錛屾湰韜茍涓嶅叿澶囦簨鍔$鐞嗚兘鍔涳紝鍦ㄤ簨鍔$鐞嗗眰錛孒ibernate灝嗗叾濮旀墭緇欏簳灞傜殑JDBC鎴栬匤TA,浠ュ疄鐜頒簨鍔$殑綆$悊鍜岃皟搴︺?/p>

  Hibernate鐨勯粯璁や簨鍔″鐞嗘満鍒跺熀浜嶫DBCTransaction錛屼篃鍙互閫氳繃閰嶇疆鏂囦歡璁懼畾閲囩敤JTA浣滀負浜嬪姟綆$悊瀹炵幇錛?/p>

   <hibernate-configuration>

        <session-factory>

    ……

             <property name = "hibernate.transaction.factory_class">

     net.sf.hibernate.transaction.JTATransactionFactory

    </session-factory>

   </hibernate-configuration>

1銆佸熀浜嶫DBC鐨勪簨鍔$鐞?/p>

  Hibernate瀵逛簬JDBC浜嬪姟鐨勫皝瑁呴潪甯哥畝鍗曘備緥濡傦細

   session=sessionFactory.openSession();

   Transaction tx= session.beginTransaction();

   ……

   tx.commit();

榪欓噷瑕佹敞鎰忕殑鏄紝鍦╯essionFactory.openSession()涓紝Hibernate浼氬垵濮嬪寲鏁版嵁搴撹繛鎺ワ紝涓庢鍚屾椂錛屽皢鍏?AutoCommit璁句負鍏抽棴鐘舵侊紝榪欏氨鏄錛屼粠SessionFactory鑾峰緱session錛屽叾鑷姩鎻愪氦灞炴у氨宸茬粡琚叧闂簡錛屼笅闈㈢殑浠g爜涓嶄細瀵逛簨鍔℃ф暟鎹簱浜х敓浠諱綍鏁堟灉銆?/p>

   session=sessionFactory.openSession();

   session.save(user);

   session.close();

濡傛灉瑕佷嬌寰椾唬鐮佺湡姝d綔鐢ㄥ埌鏁版嵁搴擄紝蹇呴』鏄劇ず鐨勮皟鐢═ransaction鎸囦護

   session=sessionFactory.openSession();

   Transaction tx = session.beginTransaction();

   session.save(user);

   tx.commit();

   session.close();

2銆佸熀浜嶫TA鐨勪簨鍔$鐞?/p>

  JTA鎻愪緵浜嗚法Session鐨勪簨鍔$鐞嗚兘鍔涳紝榪欐槸涓嶫DBCTransaction鏈澶х殑宸紓銆?/p>

 JDBC浜嬪姟鐢盋onnection綆$悊錛屼篃灝辨槸璇達紝浜嬪姟綆$悊瀹為檯涓婃槸鍦↗DBC Connection涓疄鐜幫紝浜嬪姟鍛ㄦ湡闄愪簬Connection鐨勭敓鍛藉懆鏈熶箣鍐咃紝瀵逛簬鍩轟簬JDBC Transaction鐨凥ibernate浜嬪姟綆$悊鏈哄埗錛屼簨鍔$鐞嗗湪Session鎵渚濇墭鐨凧DBC Connection涓疄鐜幫紝浜嬪姟鍛ㄦ湡闄愪簬Session鐨勭敓鍛藉懆鏈熴?/p>

   JTA浜嬪姟綆$悊鐢盝TA瀹瑰櫒瀹炵幇錛孞TA瀹瑰櫒瀵瑰綋鍓嶅姞鍏ヤ簨鍔$殑浼楀Connection榪涜璋冨害錛屽疄鐜板叾浜嬪姟鎬ц姹傦紝JTA鐨勪簨鍔″懆鏈熷彲妯法澶氫釜JDBC Connection鐢熷懡鍛ㄦ湡錛屽悓鏍鳳紝瀵瑰熀浜嶫TA浜嬪姟鐨凥ibernate錛孞TA浜嬪姟妯法澶氫釜Session銆傞渶瑕佹敞鎰忕殑鏄紝鍙備笌JTA浜嬪姟鐨?Connection闇閬垮厤瀵逛簨鍔$鐞嗚繘琛屽共娑夛紝濡傛灉閲囩敤JTA Transaction錛屽氨涓嶅簲璇ュ啀璋冪敤Hibernate鐨凾ransaction鍔熻兘銆?br> 
 



]]>
JDBC Transaction涓嶫TA Transaction鐨勫尯鍒?/title><link>http://www.tkk7.com/jesson2005/articles/113519.html</link><dc:creator>寮犻噾楣?/dc:creator><author>寮犻噾楣?/author><pubDate>Wed, 25 Apr 2007 06:11:00 GMT</pubDate><guid>http://www.tkk7.com/jesson2005/articles/113519.html</guid><wfw:comment>http://www.tkk7.com/jesson2005/comments/113519.html</wfw:comment><comments>http://www.tkk7.com/jesson2005/articles/113519.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/jesson2005/comments/commentRss/113519.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/jesson2005/services/trackbacks/113519.html</trackback:ping><description><![CDATA[Hibernate鏄JDBC鐨勮交閲忕駭瀵硅薄灝佽錛孒ibernate鏈韓鏄笉鍏峰Transaction澶勭悊鍔熻兘鐨勶紝Hibernate鐨凾ransaction瀹為檯涓婃槸搴曞眰鐨凧DBC Transaction鐨勫皝瑁咃紝鎴栬呮槸JTA Transaction鐨勫皝瑁咃紝涓嬮潰鎴戜滑璇︾粏鐨勫垎鏋愶細 <br><br>銆銆Hibernate鍙互閰嶇疆涓篔DBCTransaction鎴栬呮槸JTATransaction錛岃繖鍙栧喅浜庝綘鍦╤ibernate.properties涓殑閰嶇疆: <br><br>銆銆#hibernate.transaction.factory_class <br>銆銆net.sf.hibernate.transaction.JTATransactionFactory <br>銆銆#hibernate.transaction.factory_class <br>銆銆net.sf.hibernate.transaction.JDBCTransactionFactory <br><br>銆銆濡傛灉浣犱粈涔堥兘涓嶉厤緗紝榛樿鎯呭喌涓嬩嬌鐢↗DBCTransaction錛屽鏋滀綘閰嶇疆涓猴細 <br><br>銆銆hibernate.transaction.factory_class <br>銆銆net.sf.hibernate.transaction.JTATransactionFactory <br><br>銆銆灝嗕嬌鐢↗TATransaction錛屼笉綆′綘鍑嗗璁〩ibernate浣跨敤JDBCTransaction錛岃繕鏄疛TATransaction錛屾垜鐨勫繝鍛婂氨鏄粈涔堥兘涓嶉厤錛屽皢璁╁畠淇濇寔榛樿鐘舵侊紝濡備笅錛?<br><br>銆銆#hibernate.transaction.factory_class <br>銆銆net.sf.hibernate.transaction.JTATransactionFactory <br>銆銆#hibernate.transaction.factory_class <br>銆銆net.sf.hibernate.transaction.JDBCTransactionFactory <br><br>銆銆鍦ㄤ笅闈㈢殑鍒嗘瀽涓垜浼氱粰鍑哄師鍥犮?<br><br>銆銆<strong>涓銆丣DBC Transaction <br></strong><br>銆銆鐪嬬湅浣跨敤JDBC Transaction鐨勬椂鍊欐垜浠殑浠g爜渚嬪瓙錛?<br><br>銆銆Session session = sf.openSession(); <br>銆銆Transaction tx = session.beginTransactioin(); <br>銆銆... <br>銆銆session.flush(); <br>銆銆tx.commit(); <br>銆銆session.close(); <br><br>銆銆榪欐槸榛樿鐨勬儏鍐碉紝褰撲綘鍦ㄤ唬鐮佷腑浣跨敤Hibernate鐨凾ransaction鐨勬椂鍊欏疄闄呬笂灝辨槸JDBCTransaction銆傞偅涔圝DBCTransaction絀剁珶鏄粈涔堜笢瑗垮憿錛熸潵鐪嬬湅婧愪唬鐮佸氨娓呮浜嗭細 <br><br>銆銆Hibernate2.0.3婧愪唬鐮佷腑鐨勭被 <br><br>銆銆net.sf.hibernate.transaction.JDBCTransaction: <br><br>銆銆public void begin() throws HibernateException { <br>銆銆... <br>銆銆if (toggleAutoCommit) session.connection().setAutoCommit(false); <br>銆銆... <br>銆銆} <br><br>銆銆榪欐槸鍚姩Transaction鐨勬柟娉曪紝鐪嬪埌 connection().setAutoCommit(false) 浜嗗悧錛熸槸涓嶆槸寰堢啛鎮夛紵 <br><br>銆銆鍐嶆潵鐪?<br><br>銆銆public void commit() throws HibernateException { <br>銆銆... <br>銆銆try { <br>銆銆if ( session.getFlushMode()!=FlushMode.NEVER ) session.flush(); <br>銆銆try { <br>銆銆session.connection().commit(); <br>銆銆committed = true; <br>銆銆} <br>銆銆... <br>銆銆toggleAutoCommit(); <br>銆銆} <br><br>銆銆榪欐槸鎻愪氦鏂規硶錛岀湅鍒癱onnection().commit() 浜嗗悧錛熶笅闈㈠氨涓嶇敤鎴戝璇翠簡錛岃繖涓被浠g爜闈炲父綆鍗曟槗鎳傦紝閫氳繃闃呰浣挎垜浠槑鐧紿ibernate鐨凾ransaction閮藉湪騫蹭簡浜涗粈涔堬紵鎴戠幇鍦ㄦ妸鐢℉ibernate鍐欑殑渚嬪瓙緲昏瘧鎴怞DBC錛屽ぇ瀹跺氨涓鐩簡鐒朵簡錛?<br><br>銆銆Connection conn = ...; <--- session = sf.openSession(); <br>銆銆conn.setAutoCommit(false); <--- tx = session.beginTransactioin(); <br>銆銆... <--- ... <br>銆銆conn.commit(); <--- tx.commit(); (瀵瑰簲宸﹁竟鐨勪袱鍙? <br>銆銆conn.setAutoCommit(true); <br>銆銆conn.close(); <--- session.close(); <br><br>銆銆鐪嬫槑鐧戒簡鍚э紝Hibernate鐨凧DBCTransaction鏍規湰灝辨槸conn.commit鑰屽凡錛屾牴鏈鏃犵縐樺彲璦錛屽彧涓嶈繃鍦℉ibernate涓紝Session鎵撳紑鐨勬椂鍊欙紝灝變細鑷姩conn.setAutoCommit(false)錛屼笉鍍忎竴鑸殑JDBC錛岄粯璁ら兘鏄痶rue錛屾墍浠ヤ綘鏈鍚庝笉鍐檆ommit涔熸病鏈夊叧緋伙紝鐢變簬Hibernate宸茬粡鎶夾utoCommit緇欏叧鎺変簡錛屾墍浠ョ敤Hibernate鐨勬椂鍊欙紝浣犲湪紼嬪簭涓笉鍐橳ransaction鐨勮瘽錛屾暟鎹簱鏍規湰灝辨病鏈夊弽搴斻?<br><br>銆銆<strong>浜屻丣TATransaction <br></strong><br>銆銆濡傛灉浣犲湪EJB涓嬌鐢℉ibernate錛屾垨鑰呭噯澶囩敤JTA鏉ョ鐞嗚法Session鐨勯暱浜嬪姟錛岄偅涔堝氨闇瑕佷嬌鐢↗TATransaction錛屽厛鐪嬩竴涓緥瀛愶細 <br><br>銆銆javax.transaction.UserTransaction tx = new <br>銆銆InitialContext().lookup("javax.transaction.UserTransaction"); <br>銆銆Session s1 = sf.openSession(); <br>銆銆... <br>銆銆s1.flush(); <br>銆銆s1.close(); <br>銆銆... <br>銆銆Session s2 = sf.openSession(); <br>銆銆... <br>銆銆s2.flush(); <br>銆銆s2.close(); <br>銆銆tx.commit(); <br><br>銆銆榪欐槸鏍囧噯鐨勪嬌鐢↗TA鐨勪唬鐮佺墖鏂紝Transaction鏄法Session鐨勶紝瀹冪殑鐢熷懡鍛ㄦ湡姣擲ession瑕侀暱銆傚鏋滀綘鍦‥JB涓嬌鐢℉ibernate錛岄偅涔堟槸鏈綆鍗曚笉榪囩殑浜嗭紝浣犱粈涔圱ransaction浠g爜緇熺粺閮戒笉瑕佸啓浜嗭紝鐩存帴鍦‥JB鐨勯儴緗叉弿榪扮涓婇厤緗煇鏌愭柟娉曟槸鍚︿嬌鐢ㄤ簨鍔″氨鍙互浜嗐?<br><br>銆銆鐜板湪鎴戜滑鏉ュ垎鏋愪竴涓婮TATransaction鐨勬簮浠g爜錛?net.sf.hibernate.transaction.JTATransaction: <br><br>銆銆public void begin(InitialContext context, ... <br>銆銆... <br>銆銆ut = (UserTransaction) context.lookup(utName); <br>銆銆... <br><br>銆銆鐪嬫竻妤氫簡鍚楋紵 鍜屾垜涓婇潰鍐欑殑浠g爜 tx = new Initial Context?().lookup("javax.transaction.UserTransaction"); 鏄笉鏄畬鍏ㄤ竴鏍鳳紵 <br><br>銆銆public void commit() ... <br>銆銆... <br>銆銆if (newTransaction) ut.commit(); <br>銆銆... <br><br>銆銆JTATransaction鐨勬帶鍒剁◢寰鏉傦紝涓嶈繃浠嶇劧鍙互寰堟竻妤氱殑鐪嬪嚭鏉ibernate鏄浣曞皝瑁匤TA鐨凾ransaction浠g爜鐨勩?<br><br>銆銆浣嗘槸浣犵幇鍦ㄦ槸鍚︾湅鍒頒簡浠涔堥棶棰橈紵 浠旂粏鎯充竴涓嬶紝Hibernate Transaction鏄粠Session涓幏寰楃殑錛宼x = session.beginTransaction()錛屾渶鍚庤鍏堟彁浜x錛岀劧鍚庡啀session.close錛岃繖瀹屽叏絎﹀悎JDBC鐨凾ransaction鐨勬搷浣滈『搴忥紝浣嗘槸榪欎釜欏哄簭鏄拰JTA鐨凾ransactioin鎿嶄綔欏哄簭褰誨簳鐭涚浘鐨勶紒錛侊紒 JTA鏄厛鍚姩Transaction錛岀劧鍚庡惎鍔⊿ession錛屽叧闂璖ession錛屾渶鍚庢彁浜ransaction錛屽洜姝ゅ綋浣犱嬌鐢↗TA鐨凾ransaction鐨勬椂鍊欙紝閭d箞灝卞崈涓囦笉瑕佷嬌鐢℉ibernate鐨凾ransaction錛岃屾槸搴旇鍍忔垜涓婇潰鐨凧TA鐨勪唬鐮佺墖鏂偅鏍蜂嬌鐢ㄦ墠琛屻?<br><br>銆銆鎬葷粨錛?<br><br>銆銆1銆佸湪JDBC涓婁嬌鐢℉ibernate 蹇呴』鍐欎笂Hibernate Transaction浠g爜錛屽惁鍒欐暟鎹簱娌℃湁鍙嶅簲銆傛鏃禜ibernate鐨凾ransaction灝辨槸Connection.commit鑰屽凡 <br><br>銆銆2銆佸湪JTA涓婁嬌鐢℉ibernate 鍐橨TA鐨凾ransaction浠g爜錛屼笉瑕佸啓Hibernate鐨凾ransaction浠g爜錛屽惁鍒欑▼搴忎細鎶ラ敊 <br><br>銆銆3銆佸湪EJB涓婁嬌鐢℉ibernate 浠涔圱ransactioin浠g爜閮戒笉瑕佸啓錛屽湪EJB鐨勯儴緗叉弿榪扮閲岄潰閰嶇疆 <br><br>銆銆|---CMT(Container Managed Transaction) <br>銆銆| <br>銆銆|---BMT(Bean Managed Transaction) <br>銆銆| <br>銆銆|----JDBC Transaction <br>銆銆| <br>銆銆|----JTA Transaction <br clear=all> <img src ="http://www.tkk7.com/jesson2005/aggbug/113519.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/jesson2005/" target="_blank">寮犻噾楣?/a> 2007-04-25 14:11 <a href="http://www.tkk7.com/jesson2005/articles/113519.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item></channel></rss> <footer> <div class="friendship-link"> <p>感谢您访问我们的网站,您可能还对以下资源感兴趣:</p> <a href="http://www.tkk7.com/" title="亚洲av成人片在线观看">亚洲av成人片在线观看</a> <div class="friend-links"> </div> </div> </footer> 主站蜘蛛池模板: <a href="http://xjdz8.com" target="_blank">国产一区二区三区在线观看免费</a>| <a href="http://88bgbg.com" target="_blank">蜜桃视频在线观看免费网址入口</a>| <a href="http://j3223.com" target="_blank">免费在线观看黄网</a>| <a href="http://9981tv.com" target="_blank">亚洲av中文无码乱人伦在线观看</a>| <a href="http://ynyinglie.com" target="_blank">1000部拍拍拍18勿入免费视频软件 </a>| <a href="http://xmllhb.com" target="_blank">亚洲国产V高清在线观看</a>| <a href="http://www-533999.com" target="_blank">亚洲欧美黑人猛交群</a>| <a href="http://wwwkk2347.com" target="_blank">在线看片人成视频免费无遮挡</a>| <a href="http://https357171.com" target="_blank">久久久久亚洲国产</a>| <a href="http://www-xg5777.com" target="_blank">精品国产免费观看一区</a>| <a href="http://yeshenghuowang.com" target="_blank">亚洲综合色7777情网站777</a>| <a href="http://276194.com" target="_blank">特级做A爰片毛片免费69 </a>| <a href="http://4438xa48.com" target="_blank">亚洲毛片免费观看</a>| <a href="http://xiaojiejieav.com" target="_blank">亚洲电影在线免费观看</a>| <a href="http://sdsupuchem.com" target="_blank">国产在线观看免费观看不卡 </a>| <a href="http://my637.com" target="_blank">黄页网站在线免费观看</a>| <a href="http://cytanhuang.com" target="_blank">亚洲情a成黄在线观看</a>| <a href="http://gdsanhai.com" target="_blank">岛国精品一区免费视频在线观看 </a>| <a href="http://dw168cn.com" target="_blank">成人浮力影院免费看</a>| <a href="http://zjfxjy.com" target="_blank">亚洲中文精品久久久久久不卡</a>| <a href="http://116com.com" target="_blank">免费无码一区二区三区蜜桃大</a>| <a href="http://6609929.com" target="_blank">亚洲6080yy久久无码产自国产</a>| <a href="http://vc77777.com" target="_blank">免费在线观看你懂的</a>| <a href="http://0755szyxcm.com" target="_blank">a级男女仿爱免费视频</a>| <a href="http://9qwx.com" target="_blank">亚洲国产精品成人综合久久久</a>| <a href="http://alankell.com" target="_blank">成人在线免费观看</a>| <a href="http://dd5566.com" target="_blank">一级毛片在线免费视频</a>| <a href="http://72c5.com" target="_blank">亚洲久本草在线中文字幕</a>| <a href="http://www77714.com" target="_blank">老司机在线免费视频</a>| <a href="http://xass1.com" target="_blank">四虎国产精品永免费</a>| <a href="http://hbtelong.com" target="_blank">午夜亚洲www湿好大</a>| <a href="http://yaboxxx125.com" target="_blank">免费视频淫片aa毛片</a>| <a href="http://www5g9.com" target="_blank">91视频免费观看</a>| <a href="http://niu44.com" target="_blank">亚洲日韩乱码中文字幕</a>| <a href="http://fjwkjx.com" target="_blank">国产AV无码专区亚洲AV手机麻豆 </a>| <a href="http://jmdehong.com" target="_blank">久久国产精品2020免费m3u8</a>| <a href="http://miliwo.com" target="_blank">亚洲三级在线免费观看</a>| <a href="http://wuhhz.com" target="_blank">国产日产亚洲系列最新</a>| <a href="http://phlinhng.com" target="_blank">免费观看激色视频网站bd</a>| <a href="http://xiaochidaquan.com" target="_blank">美女黄频a美女大全免费皮</a>| <a href="http://qimiaodh.com" target="_blank">亚洲免费在线视频</a>| <script> (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })(); </script> </body>