wiflish
          Loving Life! Loving Coding!
          posts - 98,comments - 98,trackbacks - 0
          <2007年4月>
          25262728293031
          1234567
          891011121314
          15161718192021
          22232425262728
          293012345

          常用鏈接

          留言簿(11)

          隨筆分類(lèi)

          隨筆檔案

          相冊(cè)

          CSS技術(shù)

          Java技術(shù)

          RSS訂閱

          搜索

          •  

          最新評(píng)論

          閱讀排行榜

          評(píng)論排行榜

          在web.xml文件中配置OpenSessionInViewFilter

          ????
          <filter>
          ????????
          <filter-name>hibernateFilter</filter-name>
          ????????
          <filter-class>
          ????????????org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
          ????????
          </filter-class>
          ??? </filter>
          在spring的事務(wù)配置中:
          <aop:config>
          ????
          <aop:advisor?id="managerTx"?advice-ref="txAdvice"
          ????????pointcut
          ="execution(*?*..service.*Manager.*(..))"?order="2"?/>
          </aop:config>

          <tx:advice?id="txAdvice">
          ????
          <tx:attributes>
          ????????
          <tx:method?name="get*"?read-only="true"?/>
          ????????
          <tx:method?name="find*"?read-only="true"?/>
          ????????
          <tx:method?name="*"?/>
          ????
          </tx:attributes>
          </tx:advice>

          這樣的配置,當(dāng)在容器中通過(guò)action調(diào)用service代碼保存對(duì)象時(shí),不能成功保存對(duì)象,
          同時(shí)出現(xiàn)如下類(lèi)似錯(cuò)誤:
          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.

          這時(shí)修改filter的配置,增加如下代碼:
          ????<filter>
          ????????
          <filter-name>hibernateFilter</filter-name>
          ????????
          <filter-class>
          ????????????org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
          ????????
          </filter-class>
          ????????
          <init-param>
          ????????????
          <param-name>singleSession</param-name>
          ????????????
          <param-value>false</param-value>
          ????????
          </init-param>
          ????
          </filter>

          這樣就能成功保存對(duì)象了。

          ===================================================================
          額。。。上面那個(gè)配置等于不用OpenSessionInViewFilter。。。 沒(méi)意義。。

          posted on 2007-04-11 20:33 想飛的魚(yú) 閱讀(4769) 評(píng)論(3)  編輯  收藏 所屬分類(lèi): framework

          FeedBack:
          # re: 關(guān)于OpenSessionInViewFilter的配置
          2007-04-13 17:04 | shydow
          這等于沒(méi)有使用open session in view  回復(fù)  更多評(píng)論
            
          # re: 關(guān)于OpenSessionInViewFilter的配置
          2008-08-21 16:00 | neo
          這種貼也來(lái)發(fā),根本沒(méi)有搞清發(fā)生問(wèn)題的原因是什么,你是繞過(guò)了問(wèn)題,但是又遇上了一個(gè)新問(wèn)題,就如樓上所說(shuō)  回復(fù)  更多評(píng)論
            
          # re: 關(guān)于OpenSessionInViewFilter的配置
          2009-04-28 16:57 | 11
          確實(shí),問(wèn)題是一個(gè)接一個(gè)的來(lái),
          Connection is read-only. Queries leading to data modification are not allowed  回復(fù)  更多評(píng)論
            
          主站蜘蛛池模板: 民县| 彰武县| 铁岭县| 保山市| 张家港市| 黄浦区| 达孜县| 涿鹿县| 泗水县| 临邑县| 台江县| 罗田县| 平远县| 余庆县| 云浮市| 威远县| 丹江口市| 荥经县| 承德市| 大厂| 聂荣县| 无棣县| 资讯 | 博客| 偏关县| 普兰店市| 特克斯县| 神农架林区| 英德市| 宜兰县| 郁南县| 清苑县| 邵阳市| 荣成市| 天柱县| 宣威市| 陵川县| 巴彦县| 内黄县| 凭祥市| 新田县|