org.springframework.orm.hibernate3.support.OpenSessionInViewFilter作用
在Spring与Hibernate集成时在web.xml要加入这样的过滤器:
<filter>
<filter-name>openSessionInView</filter-name>
<filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
<init-param>
<param-name>sessionFactoryBeanName</param-name>
<param-value>sessionFactory</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>openSessionInView</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
请问这个过滤器的作用是:
OpenSessionInViewFilter是Spring提供的一个针对Hibernate的一个支持类,其主要意思是在发起一个页面请求时打开Hibernate的Session,一直保持这个Session,直到这个请求结束,具体是通过一个Filter来实现的。
由于Hibernate引入了Lazy Load特性,使得脱离Hibernate的Session周期的对象如果再想通过getter方法取到其关联对象的值,Hibernate会抛出一个LazyLoad的Exception。所以为了解决这个问题,Spring引入了这个Filter,使得Hibernate的Session的生命周期变长。
opensessioninview是结合 hibernateTemplete在存在延迟加载的情况下来用的 由于模板方法中hibernatepemplete默认打开一个session并在并在最后关闭session 这时候用hibernatepemplete如果取到一个对象A该对象内存在延迟加载的对象B 而想要调用A.getB()的话就会出现显示session已经关闭。 opensessioninview 主要为了解决该为题~~~~~~~~~~~~~~~是的session在请求完毕最后关闭。
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter作用的更多相关文章
- ssh中org.springframework.orm.hibernate4.support.OpenSessionInViewFilter的作用及配置
org.springframework.orm.hibernate4.support.OpenSessionInViewFilter 是Spring为我们解决Hibernate的Session的关闭 ...
- org.springframework.orm.hibernate4.support.OpenSessionInViewFilter
---恢复内容开始--- /* * Copyright 2002-2014 the original author or authors. * * Licensed under the Apache ...
- org.springframework.orm.hibernate3.HibernateSystemException:
org.springframework.orm.hibernate3.HibernateSystemException: The database returned no natively gener ...
- hibernate4 , spring3 使用 org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean 报错 Implementing class
错误代码如下 Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with ...
- java.lang.ClassNotFoundException: org.springframework.orm.hibernate3.LocalSessionFactoryBean
Caused by: java.lang.ClassNotFoundException: org.springframework.orm.hibernate3.LocalSessionFactoryB ...
- org.springframework.orm.hibernate4.support.OpenSessionInterceptor
/* * Copyright 2002-2014 the original author or authors. * * Licensed under the Apache License, Vers ...
- Initializing connection provider: org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider停住了
2015.1.24进行了服务器的搬家,搬家后,更换了新的IP,导致新的IP访问以前IP的数据库服务无法成功Initializing connection provider: org.springfra ...
- org.springframework.orm.hibernate3.LocalSessionFactoryBean的疑惑解决办法
在项目中使用了SSH框架(Struts2 + Spring3+ Hibernate3),applicationContext中配置了sessionFactory <bean id="s ...
- applicationContext.xml报错org.springframework.orm.hibernate3.LocalSessionFactoryBean not found
applicationContext.xml报错org.springframework.orm.hibernate3.LocalSessionFactoryBean not found 解决办法: 1 ...
随机推荐
- linux基础命令学习(六)DHCP服务器配置
工作原理: 1.客户机寻找服务器:广播发送discover包,寻找dhcp服务器 2.服务器响应请求:单播发送offer包,对客户机做出响应.提供客户端网络相关的租约以供选 ...
- 几种判断asp.net中session过期方法的比较
方法一:最麻烦也是最容易想到的方法,在每个页面的page_load()方法里面判断: protected void Page_Load(object sender, EventArgs e) { if ...
- 实现:TextView自由复制功能
源代码已经上传,链接地址:http://download.csdn.net/detail/huangyabin001/7556825 点击打开链接 package com.example.copyfr ...
- 前端页面js与flash交互——js获取flash对象,并传递参数
背景介绍: 最近在搞一个项目,涉及到图片选取,裁剪,上传等,由于浏览器安全性问题,js无法获取到<input type="file">中选取的文件路径,而且对照片的裁剪 ...
- 步步入佳境---UI入门(4) --简单练习
一,创建SingleViewApplication 1,UILabel的简单使用 UILabel *label=[[UILabel alloc]initWithFrame:CGRectMake(0, ...
- mysql 远程连接失败(linux)
主要有三个原因:1.mysql授权表里没有远程机器的权限,及需要在授权表mysql.user添加grant all privileges on *.* to 'root'@'远程登陆IP' ident ...
- magento关于站点搬家,换空间
1,先把原来空间的文件全部压缩后(有些不要的就不要压缩)下载下来,然后传到新空间去,注意下载下来后核对一下是否大小一样,建议使用ftp工具下载, 2,同样把原来空间的数据库打包下来,再在新空间创建一个 ...
- BS模式的模型结构详解
编号:1004时间:2016年4月12日16:59:17功能:BS模式的模型结构详解 URL:http://blog.csdn.net/icerock2000/article/details/4000 ...
- USB相关的网络资料
相关资源连接: USB官网:http://www.usb.org/home <USB in a NutShell>: http://www.beyondlogic.org/usbnutsh ...
- Linux 安装挂载时注意事项
Linux系统下使用的是目录树系统,所以安装的时候要规划磁盘分区与目录树的挂载.实际上,在Linux系统安装的时候已经提供了相当多的默认模式让你选择分割的方式了,不过无论如何,分割的结果可能都不是能符 ...