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

          主站蜘蛛池模板: 治县。| 浪卡子县| 嘉定区| 寿宁县| 吉首市| 禄劝| 靖边县| 三亚市| 宝应县| 榆林市| 荥阳市| 永宁县| 靖宇县| 和田市| 阿拉尔市| 新泰市| 错那县| 莱州市| 武宣县| 沙河市| 徐水县| 汾西县| 虹口区| 且末县| 阿克苏市| 会宁县| 苏尼特右旗| 黎平县| 岳阳县| 资源县| 连州市| 东海县| 蓬溪县| 峡江县| 沛县| 西林县| 广元市| 镇巴县| 湾仔区| 左权县| 临沂市|