(Detailed description) Write operations are not allowed in read-only mode (FlushMode. NEVER/MANUAL): Turn your Session

Source: Internet
Author: User

Yesterday, we found that the previous normal function reported an error. The error log is as follows:

Error log: Hibernate: select taxtypecon0 _. ID as ID62 _, taxtypecon0 _. TAX_TYPE_NAME as TAX2_62 _, taxtypecon0 _. EXPRESSIONS as expres1__62 _, taxtypecon0 _. CREATE_DATE as CREATE4_62 _, taxtypecon0 _. CREATED_BY as CREATED5_62 _, taxtypecon0 _. LAST_UPDATE_DATE as LAST6_62 _, taxtypecon0 _. LAST_UPDATED_BY as LAST7_62 _, taxtypecon0 _. type_kind as type8_62 _, taxtypecon0 _. VALID_DATE_START as VALID9_62 _, taxtypecon0 _. VALID_DATE_END as VALID10_62 _, taxtypecon0 _. IS_VALID as IS11_62 _ from tb_TAXTYPE_CONFIG taxtypecon0 _ where (taxtypecon0 _. type_kind = 1) order by taxtypecon0 _. CREATE_DATE deschib.pdf: select taxtypecon0 _. ID as ID62 _, taxtypecon0 _. TAX_TYPE_NAME as TAX2_62 _, taxtypecon0 _. EXPRESSIONS as expres1__62 _, taxtypecon0 _. CREATE_DATE as CREATE4_62 _, taxtypecon0 _. CREATED_BY as CREATED5_62 _, taxtypecon0 _. LAST_UPDATE_DATE as LAST6_62 _, taxtypecon0 _. LAST_UPDATED_BY as LAST7_62 _, taxtypecon0 _. type_kind as type8_62 _, taxtypecon0 _. VALID_DATE_START as VALID9_62 _, taxtypecon0 _. VALID_DATE_END as VALID10_62 _, taxtypecon0 _. IS_VALID as IS11_62 _ from tb_TAXTYPE_CONFIG taxtypecon0 _ where (taxtypecon0 _. ID = 101) org. springframework. dao. invalidDataAccessApiUsageException: Write operations are not allowed in read-only mode (FlushMode. NEVER/MANUAL): Turn your Session into FlushMode. COMMIT/AUTO or remove 'readonly' marker from transaction definition. at org. springframework. orm. hibernate3.HibernateTemplate. checkWriteOperationAllowed (HibernateTemplate. java: 1186) at org. springframework. orm. hibernate3.HibernateTemplate $16. doInHibernate (HibernateTemplate. java: 750) at org. springframework. orm. hibernate3.HibernateTemplate. doExecute (HibernateTemplate. java: 419) at org.springframework.orm.hibernate3.HibernateTemplate.exe cuteWithNativeSession (HibernateTemplate. java: 374) at org. springframework. orm. hibernate3.HibernateTemplate. saveOrUpdate (HibernateTemplate. java: 748) at com. linkage. framework. pub. dao. baseDao. saveOrUpdate (BaseDao. java: 65) at com. linkage. budgetNew. cform. dao. impl. taxtypeConfigDaoImpl. saveTaxtype (TaxtypeConfigDaoImpl. java: 33) at com. linkage. budgetNew. cform. service. impl. taxtypeConfigServiceImpl. saveTaxtype (TaxtypeConfigServiceImpl. java: 24) at com. linkage. budgetNew. cform. service. impl. taxtypeConfigServiceImpl $ FastClassByCGLIB $766ec933. invoke (<generated>) at net. sf. cglib. proxy. methodProxy. invoke (MethodProxy. java: 191) at org. springframework. aop. framework. cglib2AopProxy $ CglibMethodInvocation. invokeJoinpoint (Cglib2AopProxy. java: 700) at org. springframework. aop. framework. reflectiveMethodInvocation. proceed (ReflectiveMethodInvocation. java: 149) at org. springframework. transaction. interceptor. transactionInterceptor. invoke (TransactionInterceptor. java: 106) at org. springframework. aop. framework. reflectiveMethodInvocation. proceed (ReflectiveMethodInvocation. java: 171) at org. springframework. aop. interceptor. exposeInvocationInterceptor. invoke (ExposeInvocationInterceptor. java: 89) at org. springframework. aop. framework. reflectiveMethodInvocation. proceed (ReflectiveMethodInvocation. java: 171) at org. springframework. aop. framework. cglib2AopProxy $ DynamicAdvisedInterceptor. intercept (Cglib2AopProxy. java: 635) at com. linkage. budgetNew. cform. service. impl. taxtypeConfigServiceImpl $ EnhancerByCGLIB $ aa2803a3. saveTaxtype (<generated>) at com. linkage. budgetNew. cform. action. taxTypeConfigAction. saveTaxType (TaxTypeConfigAction. java: 53)

DEBUG debugging finds that an error is reported when the saveOrUpdate () method is called at the DAO layer.
Public void saveTaxtype (TaxtypeConfig)
{
SaveOrUpdate (TaxtypeConfig );
}

Compare the log:

Org. springframework. dao. invalidDataAccessApiUsageException: Write operations are not allowed in read-only mode (FlushMode. NEVER/MANUAL): Turn your Session into FlushMode. COMMIT/AUTO or remove 'readonly' marker from transaction definition.

Knowing that there is a problem with configuring Hibernate transaction management, we found that the following line was mistakenly deleted by someone else. In addition, this sentence is OK.

<Tx: method name = "save *" rollback-for = "Exception" propagation = "REQUIRED"/>
If this row does not exist, transaction management follows the bottom by default.

<Tx: method name = "*" propagation = "SUPPORTS" read-only = "true"/>
In this way, the "write operation" cannot be performed:
Write operations are not allowed in read-only mode (FlushMode. NEVER/MANUAL)

<! -- Transaction Management --> <tx: advice id = "txAdvice2" transaction-manager = "transactionManager"> <tx: attributes> <tx: method name = "do *" propagation = "REQUIRED" rollback-for = "Exception"/> <tx: method name = "add *" propagation = "REQUIRED" rollback-for = "Exception"/> <tx: method name = "save *" rollback-for = "Exception" propagation = "REQUIRED"/> <tx: method name = "del *" propagation = "REQUIRED" rollback-for = "Exception"/> <tx: method name = "mod *" propagation = "REQUIRED" rollback-for = "Exception"/> <tx: method name = "ins *" propagation = "REQUIRED" rollback-for = "Exception"/> <tx: method name = "upd *" propagation = "REQUIRED" rollback-for = "Exception"/> <tx: method name = "invoke" propagation = "REQUIRES_NEW" rollback-for = "Exception"/> <tx: method name = "*" propagation = "SUPPORTS" read-only = "true"/> </tx: attributes> </tx: advice>


(Detailed description) Write operations are not allowed in read-only mode (FlushMode. NEVER/MANUAL): Turn your Session

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.