今天上午做了一个ssh的组织机构增删改查的例子。crud还有分页都没有问题。可是今天下午我再打开试试的时候不行了,
    
分页没有问题,可是增删改都不行了。
老是报以下错误:Write operations are not allowed in read-only mode (FlushMode.NEVER/MANUAL): Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' er from transaction definition.
我上网查了一下,有的说是spring配置错了,可是刚才加入初始数据的时候是没有错的,加上了。后来没有改。
以下是spring的固定配置(觉的不是这里的问题):
 <!-- 配置事务特性 -->       
    <tx:advice id="txAdvice" transaction-manager="transactionManager">
     <tx:attributes>
     <tx:method name="add*" propagation="REQUIRED"/>
     <tx:method name="del*" propagation="REQUIRED"/>
     <tx:method name="update*" propagation="REQUIRED"/>
     <tx:method name="find*" propagation="REQUIRED"/>
     <tx:method name="*" read-only="true"/>
     </tx:attributes>
    </tx:advice>
    
    <!-- 配置那些类的方法进行事务管理 -->
    <aop:config>
     <aop:pointcut id="allManagerMethod" expression="execution (* com.djrj.oa.manager.*.*(..))"/>
     <aop:advisor advice-ref="txAdvice" pointcut-ref="allManagerMethod"/>
    </aop:config>           

解决方案 »

  1.   

    <tx:method name="find*" propagation="REQUIRED"/>--意思是该节点下面没有内容
        <tx:method name="*" read-only="true"/> 
    改成
    <tx:method name="find*" propagation="REQUIRED">
        <tx:method name="*" read-only="true"/> 
    </tx:method>
      

  2.   

    你的配置,
    <tx:advice id="txAdvice" transaction-manager="transactionManager">
        <tx:method name="find*" propagation="REQUIRED" read-only="true" />
       <tx:method name="*" propagation="REQUIRED" />
    </tx:advice> 
    用这个试下