最近在项目配置事务时报如下异常,在此请大家帮忙看看,异常信息如下:
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.
问题描述:
事务配置文件配置片段如下:
tx:attributes
/tx:attributes
/tx:advice
在程序中有一个服务层方法,调用了以find开头的方法时报上面的异常。不知为什么?
另外对查询类方法配事务时有必要指定read-only属性吗,它本身不就是只读的吗,还有指定吗?