我执行数据库操作的时候一直报出: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.
这个错误。
applicationContext.xml:
org.hibernate.dialect.MySQLDialect
update
true
update
thread
classpath:/com/sx/bean/*.hbm.xml
PROPAGATION_REQUIRED
PROPAGATION_REQUIRED
PROPAGATION_REQUIRED
readOnly
UserDao下的save方法:
public boolean save(User user) {
try
{
getHibernateTemplate().save(user);
} catch (RuntimeException e)
{
System.out.println("UserDao >> save >> " + e);
return false;
}
return true;
}
每次调用Dao方法都会报出上述那个错误,求救。。。。。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
问题已经解决!!
后来我换了一个实现方法:
<!-- 配置事务管理器 -->
Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction definition.
所有方法都是readOnly了,你应该设置*的readOnly属性为false,然后设置Insert,Update,Delete,Save等等开头的方法的readOnly为true