Org.springframework.dao.InvalidDataAccessApiUsageException Error

Source: Internet
Author: User

You encounter a org.springframework.dao.InvalidDataAccessApiUsageException error today when you debug a bug Si cho to a saveorupdate method that uses hibernatetemplate:

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

The information found on the internet explains the problem as follows:

Problem cause Analysis:

In order to solve the session closed error, but with opensessioninviewinterceptor or opensessioninviewfilter delay loading error, But when we open opensessioninviewfilter this filter flushmode has been set to manual by default, if Flushmode is manual or Nevel, during operation Hibernate sets the transaction to ReadOnly, so the following error occurs during an add, delete, or modify operation

Excerpt from: Http://www.tuicool.com/articles/N3QzMb

The other solution is to change the Flushmode to auto, and then call the Saveorupdate () method, which can now be carried out, as shown in the following example:

  

1  This  2this. hibernatetemplate.saveorupdate (unreadevent);

Org.springframework.dao.InvalidDataAccessApiUsageException Error

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.