空間站

          北極心空

            BlogJava :: 首頁(yè) :: 聯(lián)系 :: 聚合  :: 管理
            15 Posts :: 393 Stories :: 160 Comments :: 0 Trackbacks
          一般這個(gè)錯(cuò)誤是事務(wù)引起的,如果確定事務(wù)沒(méi)有問(wèn)題,還是有這個(gè)錯(cuò),可以重寫(xiě)OpenSessionInViewFilter的2個(gè)方法

          在myfaces的wiki里提供了OpenSessionInViewFilter的一個(gè)子類如下:
          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);
                  }
          }

          posted on 2008-11-12 11:21 蘆葦 閱讀(20083) 評(píng)論(4)  編輯  收藏 所屬分類: Hibernate

          Feedback

          # re: 解決Hibernate的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.問(wèn)題 2009-08-26 23:37 b
          這樣做不太好吧
            回復(fù)  更多評(píng)論
            

          # re: 解決Hibernate的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.問(wèn)題 2010-06-23 23:11 Eric_jiang
          動(dòng)不動(dòng)就重寫(xiě)?  回復(fù)  更多評(píng)論
            

          # re: 解決Hibernate的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.問(wèn)題 2011-07-20 16:59 地球乞丐
          謝謝,我的問(wèn)題解決了!  回復(fù)  更多評(píng)論
            

          # re: 解決Hibernate的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.問(wèn)題 2012-02-21 11:34 mona
          @地球乞丐
          你怎么解決的  回復(fù)  更多評(píng)論
            

          主站蜘蛛池模板: 静乐县| 剑阁县| 湛江市| 朔州市| 汉中市| 颍上县| 沾益县| 崇礼县| 来安县| 阿拉善盟| 全州县| 徐闻县| 九寨沟县| 平罗县| 竹北市| 镇巴县| 合江县| 巨野县| 漳浦县| 房产| 桑日县| 武隆县| 丰镇市| 喀喇| 邵东县| 芷江| 张家界市| 张家港市| 兴和县| 耒阳市| 长武县| 潜山县| 紫金县| 库伦旗| 民县| 绥宁县| 大荔县| 永仁县| 平罗县| 太保市| 华阴市|