更改数据报错SQLException: Connection is read-only.

近日在更改数据的时候,idea报错:
org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [springMVC] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.orm.jpa.JpaSystemException: could not execute statement; nested exception is org.hibernate.exception.GenericJDBCException: could not execute statement] with root cause
java.sql.SQLException: Connection is read-only. Queries leading to data modification are not allowed
这是因为在修改数据时,数据被设置成了只读状态。第一个可能性是在spring配置文件中,配置的事务有个是
<tx:method name=“find*” propagation=“REQUIRED” read-only=“true”/>,
这就会导致Impl方法实现层带有find名称的都会被设为只读状态,不可更改。因此更改相应方法名即可。
第二个可能就是Impl方法实现层,对应的方法上少加了@Transactional注解,因此只需要在对应的Impl方法上加注解@Transactional(read-only = false)即可。

猜你喜欢

转载自blog.csdn.net/z2014ypd/article/details/89028938