Connection is read-only. Queries leading to data modification are not allowed

Connection is read-only. Queries leading to data modification are not allowed

 

1.检查事务配置

2.检查方法命名

 

检查在诸如 loadXXXX, queryXXX 的查询方法中,是否用了update,insert ,delete 数据的操作!

 

我的出错的地方是 方法名是 :loadXXXOrAddXXX()

 

事务配置xml如下

 

<tx:advice id="txAdvice" transaction-manager="transactionManager">
        <tx:attributes>
            <tx:method name="load*" read-only="true" />
            <tx:method name="find*" read-only="true" />
            <tx:method name="query*" read-only="true" />
            <tx:method name="select*" read-only="true" />
            <tx:method name="validate*" read-only="true" />
           
            <tx:method name="add*" propagation="REQUIRED"/>
            <tx:method name="insert*" propagation="REQUIRED"/>
            <tx:method name="create*" propagation="REQUIRED"/>
            <tx:method name="save*" propagation="REQUIRED"/>
            <tx:method name="update*" propagation="REQUIRED"/>
            <tx:method name="modify*" propagation="REQUIRED"/>
            <tx:method name="delete*" propagation="REQUIRED"/>
            <tx:method name="remove*" propagation="REQUIRED"/>
            <tx:method name="do*" propagation="REQUIRED"/>
            
            <tx:method name="*" propagation="SUPPORTS"
                rollback-for="Throwable" />
        </tx:attributes>
    </tx:advice>

 

 

就是这个 <tx:method name="load*" read-only="true" /> 
 匹配了

loadXXXOrAddXXX() 这个方法名,然后connection是 readonly的,所以无法做insert的操作!

 

坑爹了!!!!

 

 

 

 

 

 

你可能感兴趣的:(事务配置)