honzeland

          記錄點(diǎn)滴。。。

          導(dǎo)航

          <2010年3月>
          28123456
          78910111213
          14151617181920
          21222324252627
          28293031123
          45678910

          留言簿(4)

          隨筆分類

          文章分類

          收藏夾

          隨筆檔案

          文章檔案

          閱讀排行榜

          評(píng)論排行榜

          常用鏈接

          統(tǒng)計(jì)

          Famous Websites

          Java

          Linux

          P2P

          最新評(píng)論

          One Hibernate Session Multiple Transactions

          The case to use One Hibernate Session Multiple Transactions:
          each transaction would NOT affect others.
          i.e., open multiple transactions on the same session, even though one transaction rolls back, other transactions can be committed. If one action fails, others should fail too, then we should use one transaction for all actions.

          Note:
          A rollback with a single Session will lead to that Session being cleared (through "Session.clear()").
          So do lazy collections still work if the session is cleared? =>Not of any objects that you loaded up until the rollback. Only for new objects loaded afterwards.
          We should load necessary objects to session for each transactional action to avoid LazyInitializationException, even if those objects are loaded before other forward transactional actions, since forward action may be rolled back and clear the session.

          BTW, Hibernate Session.merge() is different with Session.update() by:
          Item item2 = session.merge(item);
          item2 
          == item; // false, item - DETACHED, item2 - PERSIST
          session.update(item); // no return value, make item PERSIST


          posted on 2010-03-01 11:47 honzeland 閱讀(412) 評(píng)論(0)  編輯  收藏 所屬分類: Hibernate

          主站蜘蛛池模板: 科技| 长宁区| 攀枝花市| 定西市| 德庆县| 安阳县| 桑日县| 双鸭山市| 雅江县| 纳雍县| 金沙县| 马尔康县| 礼泉县| 武宣县| 芒康县| 桂阳县| 通山县| 富阳市| 门源| 山阴县| 永年县| 邻水| 巴彦县| 元江| 阳新县| 南涧| 平邑县| 新巴尔虎右旗| 阜平县| 福鼎市| 南木林县| 仙居县| 蕲春县| 宝兴县| 黔西| 通化县| 鲁甸县| 桑日县| 新竹县| 洛川县| 江孜县|