org.springframework.dao.InvalidDataAccessApiUsageException: read-only mode (FlushMode.MANUAL)
2013-03-04 14:53
453 查看
org.springframework.dao.InvalidDataAccessApiUsageException:Write operations are not allowed in read-only mode (FlushMode.MANUAL): Turnyour Session into FlushMode.COMMIT/AUTO or remove
'readOnly' marker fromtransaction definition.
今天做项目的时候出现了这个错误:是往数据里面添加,修改的时候出现的。
参考了http://blog.sina.com.cn/s/blog_656ffe730100ugtw.html 之后,改了web.xml里面的配置,可以添加了。但是删除不了。
如下:web.xml
参考了/article/6930106.html之后,添加删除都可以了。
如下:web.xml
但是有说这种方法不好。。
最后贴下我的applicationContext.xml里面的配置
'readOnly' marker fromtransaction definition.
今天做项目的时候出现了这个错误:是往数据里面添加,修改的时候出现的。
参考了http://blog.sina.com.cn/s/blog_656ffe730100ugtw.html 之后,改了web.xml里面的配置,可以添加了。但是删除不了。
如下:web.xml
<filter> <filter-name>hibernateFilter</filter-name> <filter-class> org.springframework.orm.hibernate3.support.OpenSessionInViewFilter </filter-class> <init-param> <param-name>flushMode</param-name> <param-value>AUTO</param-value> </init-param> <init-param> <param-name>singleSession</param-name> <param-value>true</param-value> </init-param> </filter>
参考了/article/6930106.html之后,添加删除都可以了。
如下:web.xml
<filter> <filter-name>hibernateFilter</filter-name> <filter-class> org.springframework.orm.hibernate3.support.OpenSessionInViewFilter </filter-class> <init-param> <param-name>singleSession</param-name> <param-value>false</param-value> </init-param> </filter>
但是有说这种方法不好。。
最后贴下我的applicationContext.xml里面的配置
<!-- 扫描 --> <context:component-scan base-package="com. "></context:component-scan> <!-- 配置数据源 --> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="com.microsoft.sqlserver.jdbc.SQLServerDriver"> </property> <property name="url" value="jdbc:sqlserver://localhost:1433;DatabaseName= "></property> <property name="username" value="sa"></property> <property name="password" value=" "></property> <!-- 数据连接池初始值 --> <property name="initialSize" value="1"></property> <!-- 数据连接池最大值 --> <property name="maxActive" value="300"></property> <!-- 数据连接池 最大空闲值 --> <property name="maxIdle" value="2"></property> <!-- 数据连接池 最小空闲值 --> <property name="minIdle" value="1"></property> </bean> <!-- 配置 sessionFactory --> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <property name="configLocation"> <value>classpath:config/hibernate/hibernate.cfg.xml</value> </property> <property name="mappingResources"> <list> <value>config/hibernate/hbm/SysUser.hbm.xml</value> </list> </property> <property name="hibernateProperties"> <value> hibernate.dialect=org.hibernate.dialect.SQLServerDialect hibernate.hbm2ddl.auto=update </value> </property> </bean> <!-- 配置事务管理器 --> <bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory"></property> </bean> <tx:annotation-driven transaction-manager="txManager" />
相关文章推荐
- hibernate框架学习错误集锦-org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read-only mode (FlushMode.MANUAL)
- 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' mar
- [spring]:org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read-only mode
- [spring]:org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read-only mode
- org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read-only mode (FlushMode.NEVER)
- org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read-only mode
- org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read
- org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read
- org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read
- org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read
- org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read
- org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read
- org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read
- org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read
- OpenSessionInViewFilter与org.springframework.dao.InvalidDataAccessApiUsageException
- org.springframework.dao.InvalidDataAccessApiUsageException问题解决
- Request processing failed; nested exception is org.springframework.dao.InvalidDataAccessApiUsageExce
- org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in r...
- org.springframework.dao.InvalidDataAccessApiUsageException: (开发错误记录)
- 异常积累:org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in