Write operations are not allowed in read-only mode (FlushMode.MANUAL): Turn your Session into FlushM

我遇到这个问题是在调用dao层的修改方法的时候报的

Write operations are not allowed in read-only mode (FlushMode.MANUAL): Turn your Session into FlushM_第1张图片

 

解决方法:

 第一步: 在spring的xml文件中加入



    
        
    



第二步:
  在service层加如下注解

Write operations are not allowed in read-only mode (FlushMode.MANUAL): Turn your Session into FlushM_第2张图片

解决方法2:

Write operations are not allowed in read-only mode (FlushMode.MANUAL): Turn your Session into FlushM_第3张图片

 

getHibernateTemplate().setCheckWriteOperations(false);

 

注:看是否配置了事务传播属性,如果设置了就注意如果方法名是find开头就只能读取不能做其他操作

Write operations are not allowed in read-only mode (FlushMode.MANUAL): Turn your Session into FlushM_第4张图片

 

你可能感兴趣的:(Write operations are not allowed in read-only mode (FlushMode.MANUAL): Turn your Session into FlushM)