Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly'
2010-07-19 16:50
561 查看
最近的一个SpringMVC+Hibernate的项目中,执行save操作的时候出现一下问题:
Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly'
搜索了很久终于找到一个好的解决办法。分享给大家。
在web.xml中:
OurOpenSessionInViewFilter的代码如下:
Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly'
搜索了很久终于找到一个好的解决办法。分享给大家。
在web.xml中:
<filter> <filter-name>CloseSessionInViewFilter</filter-name> <filter-class>org.springframework.orm.hibernate3.support.OurOpenSessionInViewFilter</filter-class> <init-param> <param-name>singleSession</param-name> <param-value>true</param-value> </init-param> </filter>
OurOpenSessionInViewFilter的代码如下:
package org.springframework.orm.hibernate3.support; import org.hibernate.*; /** * @author <a href="mailto: mackjieson@gmail.com" mce_href="mailto: mackjieson@gmail.com">zhoujie</a> * */ public class OurOpenSessionInViewFilter extends OpenSessionInViewFilter{ public OurOpenSessionInViewFilter() { super.setFlushMode(FlushMode.AUTO); } protected void closeSession(Session session, SessionFactory sessionFactory) { session.flush(); try { session.getTransaction().commit(); } catch (HibernateException e) { // TODO Auto-generated catch block//e.printStackTrace(); } super.closeSession(session, sessionFactory); } }
相关文章推荐
- Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction definition
- Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction
- 解决 Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from
- Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction definitio
- [SSH] Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction
- Write operations are not allowed in read-only mode (FlushMode.NEVER) - turn your Session into FlushMode.AUTO or remove 'readOnly
- 解决 Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from
- Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction definition
- Write operations are not allowed in read-only mode (FlushMode.NEVER) - turn your Session into FlushMode.AUTO or remove 'readOnly
- 报错原因 (FlushMode.MANUAL): Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker fr
- Write operations are not allowed in read-only mode (FlushMode.NEVER) - turn your Session into FlushMode.AUTO or remove 'readOnly
- Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction definition
- Write operations are not allowed in read-only mode (FlushMode.NEVER) - turn your Session into FlushMode.AUTO or remove 'readOnly
- Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction definition
- Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction definition
- Write operations are not allowed in read-only mode (FlushMode.NEVER/MANUAL): Turn your Session into FlushMode.COMMIT/AUTO or rem
- 解决 Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker
- 两种方法解决Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker
- spring出现 Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marke问题
- Write operations are not allowed in read-only mode (FlushMode.NEVER/MANUAL): Turn your Session into FlushMode.COMMIT/AU