- 浏览: 376408 次
- 性别:
- 来自: 北京
文章分类
最新评论
-
xujian19921202:
没有信用卡如何在iTunes注册帐号? -
sryijun:
虽然简单,但也明了,辛苦了
原创:oracle聚合函数介绍 <六> -
cnm493:
前台页面没有啊
原创:仿Baidu,Google查询分页技术JAVA实现 -
zczjdyj123:
读取页面,用字节流,再把字节数据转成特定编码字符,还是字节流好 ...
原创:ServletContext应用介绍总结 -
ljc19901124:
整合到一个参数 也报错,也没解决问题
public Ba ...
原创:Java反射java.lang.IllegalArgumentException: wrong number of arguments错误解析
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:1186) org.springframework.orm.hibernate3.HibernateTemplate$12.doInHibernate(HibernateTemplate.java:696) org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:419) org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374) org.springframework.orm.hibernate3.HibernateTemplate.save(HibernateTemplate.java:694) com.tangjie.dao.StudentDAO.save(StudentDAO.java:38) com.tangjie.model.StudentModel.save(StudentModel.java:22) com.tangjie.action.StudentAction.regist(StudentAction.java:45) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) java.lang.reflect.Method.invoke(Unknown Source) com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:441) com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:280) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:243) com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:165) com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:252) org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68) com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:122) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195) com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195) com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:179) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:94) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:235) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:89) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:130) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:267) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:126) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:138) com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:165) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:179) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:176) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52) org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:488) org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77) org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91) org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198) org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
在项目中使用ssH的时候,会开启OpenSessionInViewFilter来阻止延迟加载的错误,但是在我们开启OpenSessionInViewFilter这个过滤器的时候FlushMode就已经被默认设置为了MANUAL,如果FlushMode是MANUAL或NEVEL,在操作过程中 hibernate会将事务设置为readonly,所以在增加、删除或修改操作过程中会出现如下错误
rg.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read-only mode (FlushMode.NEVER) - turn your Session into FlushMode.AUTO or remove 'readOnly' marker from transaction definition;
解决办法:直接修改OpenSessionInViewFilter过滤器的配置,配置过滤器的时候配置时候直接指定flushMode。采用下面的方式即可:代码如下: 在web.xml文件中添加如下代码:即可解决延迟加载与上面的错误信息
<!-- hibernate由于设置了延迟加载,在action中并没有真正地查询数据 当跳到jsp页面上要显示数据时,hibernate中的session却已经关闭,导致数据无法显示 该过滤器的作用就是可以避免这种情况 --> <filter> <filter-name>OpenSessionInViewFilter</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> </filter> <filter-mapping> <filter-name>OpenSessionInViewFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
发表评论
-
原创:Struts2控制标签的解析
2010-12-14 15:51 2271Struts2的控制标签,主要用于完成流程控制,以及对Valu ... -
原创:Struts2数据标签的解析
2010-12-13 17:32 1822数据标签主要用于提供各种数据访问相关的功能,比如显示一 ... -
SSH整合注意一点:
2010-06-06 20:23 1549最近又一次使用了SSH整合,但是在Spring注入的时候会所有 ... -
Infinite recursion detected:
2010-06-06 20:21 7291Infinite recursion detected: ... -
严重: IOException while loading persisted sessions: java.io.EOFException java.i
2010-06-06 14:47 2045严重: IOException while loading ... -
ssh整合延迟加载保错的解决办法
2010-06-05 12:05 1401我们在项目中一般都会使用Spring来管理Hibern ... -
java.lang.reflect.InvocationTargetException
2010-06-04 17:51 2991HTTP Status 500 - ----------- ... -
PermGen space
2010-06-04 17:48 1416一、PermGen space PermGen space的全 ... -
cascade与inverse的使用
2010-05-24 10:38 1327关于Hibernate中 cascade 与 inverse ... -
java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.Integer
2009-09-27 14:58 14181异常信息: java.lang.ClassCastExce ... -
Exception in thread "main" java.util.ConcurrentModificationException
2009-09-26 16:52 2445public void del(int id){ s ... -
org.hibernate.MappingException
2009-09-26 10:04 2471log4j:WARN No appenders could ... -
org.hibernate.hql.ast.QuerySyntaxException
2009-09-24 16:16 11310Exception in thread "mai ... -
myeclipse中导入.war文件
2009-09-16 11:04 10369在导入war文件之前首先 新建项目 比如:web ... -
Myeclipse中开发Struts2.0项目
2009-09-15 16:04 5782开发环境的搭建: 1:添加struts2.0 ja ... -
struts2.0全局跳转,局部跳转,全局异常..
2009-09-15 16:03 62042.struts2.0的全局跳转 &l ... -
struts2.0的处理流程
2009-09-15 15:57 1594一:回顾struts2.0的处理流程 ==>>&g ... -
Struts2.0中数据的传递
2009-09-15 15:50 2334Struts2.0中数据直接的传递:[align=center ... -
javax.servlet.ServletException: No getter method for property: "Tid" of bean: "Q
2009-09-10 12:37 1377异常信息: javax.servlet.ServletEx ... -
EA用例图
2009-09-09 11:48 4094包含关系用于将部分工 ...
相关推荐
`org.springframework.orm.ObjectRetrievalFailureException`、`org.springframework.beans.factory.BeanCreationException` 和 `org.springframework.dao.InvalidDataAccessApiUsageException` 等。 #### 二、`org...
<bean name="openSessionInViewInterceptor" class="org.springframework.orm.hibernate3.support.OpenSessionInViewInterceptor"> <bean id="urlMapping" class="org.springframework.web.servlet.handler....
org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read-only mode (FlushMode.NEVER) - turn your Session into FlushMode.AUTO or remove 'readOnly' marker ...
InvalidDataAccessApiUsageException InvalidDataAccessResourceUsageException InvalidDestinationException InvalidInvocationException InvalidIsolationLevelException InvalidMetadataException ...
问题 1:如果各层都不加事务管理的话,会报错 `org.springframework.dao.InvalidDataAccessApiUsageException`。 解决方案:在各层中添加 `@Transactional` 注解,例如: ```java @Transactional public void ...