沉睡森林@漂在北京

          本處文章除注明“轉(zhuǎn)載”外均為原創(chuàng),轉(zhuǎn)載請注明出處。

            BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
            152 隨筆 :: 4 文章 :: 114 評論 :: 0 Trackbacks

          問題描述:

          Write operations are not allowed in read-only mode (FlushMode.NEVER/MANUAL): Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction definition. 

          posted on 2009-05-21 20:28 王總兵 閱讀(215) 評論(1)  編輯  收藏 所屬分類: Spring

          評論

          # re: Spring和Hibernate結(jié)合時遇到的問題 2009-05-21 20:30 王兵
          下面是轉(zhuǎn)自【http://www.aygfsteel.com/i369/articles/240039.html
          一般這個錯誤是事務(wù)引起的,如果確定事務(wù)沒有問題,還是有這個錯,可以重寫OpenSessionInViewFilter的2個方法
          在myfaces的wiki里提供了OpenSessionInViewFilter的一個子類如下:
          public class OpenSessionInViewFilter extends org.springframework.orm.hibernate3.support.OpenSessionInViewFilter {

          /**
          * we do a different flushmode than in the codebase
          * here
          */
          protected Session getSession(SessionFactory sessionFactory) throws DataAccessResourceFailureException {
          Session session = SessionFactoryUtils.getSession(sessionFactory, true);
          session.setFlushMode(FlushMode.COMMIT);
          return session;
          }
          /**
          * we do an explicit flush here just in case
          * we do not have an automated flush
          */
          protected void closeSession(Session session, SessionFactory factory) {
          session.flush();
          super.closeSession(session, factory);
          }
          }
            回復(fù)  更多評論
            

          主站蜘蛛池模板: 古浪县| 翁牛特旗| 河源市| 延寿县| 宣化县| 海盐县| 呼伦贝尔市| 天台县| 康马县| 方城县| 姚安县| 黑河市| 石门县| 德钦县| 贵定县| 淳化县| 丰宁| 天峻县| 清原| 成安县| 宜兰市| 旬阳县| 大新县| 德庆县| 睢宁县| 墨江| 贺州市| 吉水县| 武安市| 广安市| 福清市| 岢岚县| 灵武市| 临海市| 拜城县| 横峰县| 三原县| 门源| 滦平县| 扬中市| 襄城县|