瘋狂

          STANDING ON THE SHOULDERS OF GIANTS
          posts - 481, comments - 486, trackbacks - 0, articles - 1
            BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理

          關(guān)于@Transactional和配置文件混用的問題

          Posted on 2010-08-18 15:56 瘋狂 閱讀(1487) 評論(0)  編輯  收藏 所屬分類: java databasequestionsspringhibernateweb
          使用順序:
          1   <tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true" />

          之后才是xml配置:
           2  <tx:advice id="txAdviceService" transaction-manager="transactionManager">
                  <tx:attributes>
                       <tx:method name="add*" read-only="false"/>
                      <tx:method name="add*" read-only="false"/>
                      <tx:method name="update*" read-only="false"/>
                      <tx:method name="del*" read-only="false"/>
                        <tx:method name="apply*" read-only="false"/>
                      <tx:method name="*" read-only="true"/>
                  </tx:attributes>
              </tx:advice>
              <aop:config>
                     <aop:pointcut id="serviceMethods"
                      expression="execution(* com.joe.service.*.*(..))"/>
                  <aop:advisor advice-ref="txAdviceService" pointcut-ref="serviceMethods"/>
              </aop:config>
              
               <bean id="transactionManager"
                  class="org.springframework.orm.hibernate3.HibernateTransactionManager">
                  <property name="sessionFactory" ref="sessionFactory"/>
              </bean>
          如果寫反會出現(xiàn)如果使用的
          @Transactional的方法在  <tx:method name="*" read-only="true"/>
          里面 就會發(fā)現(xiàn)沒有可寫事務(wù) :
          error: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.
          主站蜘蛛池模板: 焦作市| 蓬安县| 嫩江县| 锡林浩特市| 铁力市| 琼海市| 高碑店市| 清涧县| 黄山市| 永寿县| 财经| 灵璧县| 吉水县| 茂名市| 安康市| 应用必备| 墨江| 桦川县| 常宁市| 普定县| 华池县| 特克斯县| 鞍山市| 乌拉特前旗| 胶州市| 巴彦淖尔市| 晋城| 皋兰县| 东安县| 容城县| 应城市| 东乡| 米林县| 长岭县| 石柱| 株洲县| 汉源县| 焉耆| 安义县| 内黄县| 昂仁县|