Java / Hibernate - Write operations are not allowed in read-only mode

后端 未结 11 2219
迷失自我
迷失自我 2020-11-28 11:18

I\'ve been having an annoying exception a lot lately, and after some research on Google and this forum I still haven\'t found an answer that could solve my problem.

11条回答
  •  天命终不由人
    2020-11-28 11:50

    I just stumbled onto this too. I needed to change the flush mode in Spring's OpenSessionInViewFilter to manual, and suddenly I started getting this exception. I found out that the problems were happening in methods that were not annotated as @Transactional, so I guess that Spring implicitly treats all data access code outside such methods as read only. Annotating the method solved the problem.

    Another way is to call the setCheckWriteOperations method on the HibernateTemplate object.

提交回复
热议问题