Org.springframework.dao.InvalidDataAccessApiUsageException

Source: Internet
Author: User

An error occurred while executing a method Bumenauth () in the service:

Org.springframework.dao.InvalidDataAccessApiUsageException:Write operations is not allowed in read-only mode ( Flushmode.never)-Turn your Session to Flushmode.auto or remove ' readOnly ' marker from transaction definition

To view the transaction management configuration in srping:

<bean id= "Txproxytemplate" abstract= "true"
class= "Org.springframework.transaction.interceptor.TransactionProxyFactoryBean" >
<property name= "TransactionManager" >
<ref bean= "TransactionManager"/>
</property>
<property name= "Transactionattributes" >
<props>
<prop key= "find*" >PROPAGATION_REQUIRED</prop>
<prop key= "save*" >PROPAGATION_REQUIRED</prop>
<prop key= "remove*" >PROPAGATION_REQUIRED</prop>
<prop key= "update*" >PROPAGATION_REQUIRED</prop>
<prop key= "create*" >PROPAGATION_REQUIRED</prop>
<prop key= "add*" >PROPAGATION_REQUIRED</prop>
<prop key= "del*" >PROPAGATION_REQUIRED</prop>
<prop key= "clear*" >PROPAGATION_REQUIRED</prop>
<prop key= "build*" >PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>

After looking at the original transaction strategy <prop key= "*" >PROPAGATION_REQUIRED</prop> was deleted after the Bumenauth () method after forgetting to modify, so that caused the error reported above

Modify method One:

Modify this method to update or Build,add .... Methods such as the beginning of the above policy name: Updatebumenauth ()

Modify method Two:

Add <prop key= "*" >PROPAGATION_REQUIRED</prop> can

Modify method Three:

Add Web. XML under the

<filter>
<filter-name>OpenSessionInViewFilter</filter-name>
<filter-class>
Org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
</filter-class>
<init-param>
<param-name>singleSession</param-name>
<param-value>true</param-value>
</init-param>
</filter>

The singlesession value in is modified to false, that is, does not restrict the entire process with the same session, but the disadvantage is that Hibernate session instance may be greatly increased, the use of the JDBC Connection amount will be greatly increased, If the maxpoolsize of connection pool is too small, it's easy to go wrong.

Reference: About Opensessionview (http://liuwei1578.blog.163.com/blog/static/4958036420092104215514/)

Spring Transaction Configuration Transactionproxyfactorybean (http://liuwei1578.blog.163.com/blog/static/49580364200921041136625/)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.