【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>>
org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read-only mode (FlushMode.MANUAL): Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction definition
只读模式下(FlushMode.NEVER/MANUAL)写操作不被允许:把Session改成FlushMode.COMMIT/AUTO(可以解决)
或者清除事务定义中的readOnly标记(清除readOnly标记有时不管用)
解决办法:
Session session=this.getHibernateTemplate().getSessionFactory().getCurrentSession(); session.setFlushMode(FlushMode.AUTO); // Transaction tran=session.beginTransaction(); session.saveOrUpdate(umengParams); // tran.commit();
来源:oschina
链接:https://my.oschina.net/liudandan/blog/3146752