当前位置: 代码迷 >> Java Web开发 >> error 哪位高手能帮忙解释哈什么有关问题
  详细解决方案

error 哪位高手能帮忙解释哈什么有关问题

热度:1694   发布时间:2013-02-25 21:20:33.0
error 谁能帮忙解释哈什么问题
javax.servlet.ServletException: 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.
org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:535)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:433)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75)
com.sxdx.hr.filter.EncodeFilter.doFilter(EncodeFilter.java:25)


root cause 

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.
org.springframework.orm.hibernate3.HibernateTemplate.checkWriteOperationAllowed(HibernateTemplate.java:1095)
org.springframework.orm.hibernate3.HibernateTemplate$25.doInHibernate(HibernateTemplate.java:786)
org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:372)
org.springframework.orm.hibernate3.HibernateTemplate.delete(HibernateTemplate.java:784)
org.springframework.orm.hibernate3.HibernateTemplate.delete(HibernateTemplate.java:780)
com.sxdx.hr.systemset.hrset.dao.MajorTypeDAOImpl.deleteById(MajorTypeDAOImpl.java:25)
com.sxdx.hr.systemset.hrset.service.MajorTypeServiceImpl.deleteById(MajorTypeServiceImpl.java:26)
com.sxdx.hr.systemset.hrset.web.action.MajortypeAction.doDelete(MajortypeAction.java:62)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:270)
org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:187)
org.springframework.web.struts.DelegatingActionProxy.execute(DelegatingActionProxy.java:110)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75)
com.sxdx.hr.filter.EncodeFilter.doFilter(EncodeFilter.java:25)



------解决方案--------------------------------------------------------
spring的事务管理的拦截配置有问题,read-only="true"的模式正好匹配了MajorTypeServiceImpl.deleteById方法。你要把read-only的匹配模式改掉,比如只有get*, find*之类的,不要匹配delete*
------解决方案--------------------------------------------------------
com.sxdx.hr.systemset.hrset.dao.MajorTypeDAOImpl.deleteById(MajorTypeDAOImpl.java:25)

这个方法断点调下。
------解决方案--------------------------------------------------------
  相关解决方案