honzeland

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

          常用鏈接

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

          主站蜘蛛池模板: 康马县| 大庆市| 新宾| 信阳市| 隆回县| 平度市| 东乡族自治县| 安康市| 西华县| 石楼县| 青浦区| 弥渡县| 固原市| 北安市| 清丰县| 广汉市| 深州市| 绥滨县| 海安县| 海门市| 巴林右旗| 临沭县| 寿光市| 辉县市| 闵行区| 汾阳市| 固安县| 谢通门县| 洛浦县| 镇康县| 耒阳市| 铜陵市| 卢龙县| 镇原县| 玉屏| 怀远县| 防城港市| 陈巴尔虎旗| 中江县| 佛坪县| 绥棱县|