使用OpenSessionInViewFilter的问题

问题描述

在web.xml中配置如下:<listener><listener-class>org.springframework.web.context.ContextLoaderListener</listener-class></listener><filter><filter-name>OpenSessionInViewFilter</filter-name><filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class><init-param><param-name>singleSession</param-name><param-value>true</param-value></init-param><init-param><param-name>sessionFactoryBeanName</param-name><param-value>sessionFactory</param-value></init-param></filter><filter-mapping><filter-name>OpenSessionInViewFilter</filter-name><url-pattern>/*</url-pattern></filter-mapping>在网上搜索了N天了,帖子也发了5个了,但是这样配好后还是没任何作用,抛出failedtolazilyinitializeacollectionofrole十分怀疑是我DAO的语句出了问题,我用的是:this.getHibernateTemplate().saveOrUpdate(obj);请问使用过OpenSessionInViewFilter的朋友,是用的什么语句更新对象呀?此问题困扰我很多天了,望使用过OpenSessionInViewFilter的朋友留下qq,点拨我一下,感激不尽:)

时间: 2024-07-31 00:50:34

使用OpenSessionInViewFilter的问题的相关文章

懒加载-OpenSessionInViewFilter 的配置问题

问题描述 OpenSessionInViewFilter 的配置问题 在hibernate4使用中,出现懒加载问题 但是在web.xml文件中,配置了 还是找不到Session 请问应该怎么处理??? 解决方案 http://wenku.baidu.com/link?url=ulLU1LIJ1bGvcQdjqHA7cudRVW1XhdatyQjVoQDBnaNYXKTA6gq_ETFgdkwYlEfTUv68taNB0FWD5OAQxZ202itXqbdaroCp34gVKeHjFZy

spring 的OpenSessionInViewFilter简介

假设在你的应用中Hibernate是通过spring 来管理它的session.如果在你的应用中没有使用OpenSessionInViewFilter或者OpenSessionInViewInterceptor.session会在transaction结束后关闭. 如果你采用了spring的声明式事务模式,它会对你的被代理对象的每一个方法进行事务包装(AOP的方式).如下:  <bean id="txProxyTemplate" abstract="true"

hibernate3-spring mvc OpenSessionInViewFilter hibernate 懒加载问题

问题描述 spring mvc OpenSessionInViewFilter hibernate 懒加载问题 之前做了一个项目是使用 springmvc 加hibernate 做的, 并且使用了 hibernate 的懒加载有用到OpenSessionInViewFilter, 现在做另一个项目, 基础代码都是上个项目的代码: 目前调试在调试权限模块, 核对了上个项目的代码基本完全一致,但是这个项目的老是无法使用懒加载,加载报 org.hibernate.LazyInitializationE

struts2.0-在web.xml中添加了OpenSessionInViewFilter依然有延迟加载的错误

问题描述 在web.xml中添加了OpenSessionInViewFilter依然有延迟加载的错误 web.xml <?xml version="1.0" encoding="UTF-8"?> xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocat

OpenSessionInViewFilter的问题(扩大session范围)!!

问题描述 这是我在web.xml里的配置 <filter> <filter-name>OpenSessionInViewFilter</filter-name> <filter-class> org.springframework.orm.hibernate3.support.OpenSessionInViewFilter </filter-class> <init-param> <param-name>singleSes

启动报错OpenSessionInViewFilter

问题描述 web.xml如下<?xmlversion="1.0"encoding="UTF-8"?><web-appxmlns="http://java.sun.com/xml/ns/j2ee"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"version="2.4"xsi:schemaLocation="http://j

关于Spring的OpenSessionInViewFilter的Hibernate会话

问题描述 <class name="com.cmmi.bcm.data.BcmGood" table="bcm_good" schema="dbo" lazy="true">这个表有N个外表关联,然后再web.xml中加上了过滤,成功的在web展示页面中显示每个BcmGood的数据,但是我加了WorkHibernateFilter过滤以后,其他(单表业务)模块的根本不能做相应业务处理(saveorupdate,de

Hibernate OpenSessionInViewFilter问题

问题描述 使用springmvc.spring3.0.5.hibernate3整的一个框架,hibernate使用懒加载模式时会报couldnotinitializeproxy-noSession,于是配置了OpenSessionInViewFilter,可是还是报错,通过关联spring的源码后debug,这个过滤器确实是执行了,并且创建了Session,然后去Dao层通过SessionFactory.getCurrentSession()执行操作,如下代码:protectedSessiong

spring opensessioninviewfilter问题

问题描述 在ssh2中,hibernatelazy可以用springopensessioninviewfilter解决,但我发现,如果将用户登录后的信息放入session里,这个问题就不可以解决了请问大家有没有好的解决方案 解决方案 解决方案二:最好的方式在你的业务层里,把要的东西查询出来.然后放入到session中去.解决方案三:放入Session后,此对象已是脱管状态,如果一定要使用它,首先必须让它再次进入Hibernate的管理下.解决方案四:把你要的东西取出来,然后手动的加载,在放入se