honzeland

          記錄點滴。。。

          常用鏈接

          統計

          Famous Websites

          Java

          Linux

          P2P

          最新評論

          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 閱讀(416) 評論(0)  編輯  收藏 所屬分類: Hibernate

          主站蜘蛛池模板: 黄大仙区| 鲜城| 杭锦后旗| 尉犁县| 平顺县| 堆龙德庆县| 和龙市| 尼勒克县| 白河县| 贺州市| 凉山| 通河县| 宜阳县| 应用必备| 横山县| 正定县| 盐山县| 凌源市| 北安市| 仁寿县| 开江县| 天柱县| 留坝县| 通河县| 叶城县| 临城县| 桃园县| 梨树县| 吐鲁番市| 巴里| 略阳县| 马龙县| 含山县| 出国| 襄樊市| 久治县| 中山市| 洪泽县| 特克斯县| 乐安县| 通渭县|