猿问

怎么修改hibernate 的Flush模式

在学习ssh整合的时候,报错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.

protected void checkWriteOperationAllowed(Session session) throws InvalidDataAccessApiUsageException {

if (isCheckWriteOperations() && session.getFlushMode().lessThan(FlushMode.COMMIT)) {

throw new 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为什么会默认是MANUAL,怎么修改呢?

暴躁的代码
浏览 2263回答 1
1回答

younghu

这个错误一般都是没有配置事务引起的,你在spring中配置好事务,问题应该就解决了!
随时随地看视频慕课网APP

相关分类

Java
我要回答