---
title: "Connection is read-only. Queries leading to data modification are not allowed  "
author: "waw"
date: "2014-12-04T20:10:58Z"
tags: ["事务配置"]
categories: ["企业架构"]
slug: "connection-is-read-only-queries-leading-to-data-modification-are-not-allowed"
draft: false
lastmod: "2014-12-04T20:10:53Z"
id: 2163343
url: "https://waw.iteye.com/blog/2163343"
---

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

 

1.检查事务配置

2.检查方法命名

 

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

 

我的出错的地方是 方法名是 ：loadXXXOrAddXXX（）

 

事务配置xml如下

 

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

 

 

就是这个 **&lt;tx:method name="load\*" read-only="true" /&gt;**   
 **匹配了**  
loadXXXOrAddXXX（） 这个方法名，然后connection是 readonly的，所以无法做insert的操作！

 

坑爹了！！！！