Hibernate延迟加载与opensessioninviewFilter

来源:互联网 发布:中国程序员人才需求 编辑:程序博客网 时间:2024/04/29 17:48

1、hibernate进行延迟加载时会将加载的数据放在同一个session中进行,如果在dao中进行了数据操作,那么延迟加载的数据就不能在service中进行操作。

2、通过在web.xml中配置,扩展延迟加载的范围,可以将延迟加载的范围扩展到一次请求的过程,这样在页面中也可以使用延迟加载的数据。

<!-- 将hibernate延迟加载扩展到一次请求,而不是一个session的范围 --><filter>  <filter-name>hibernateOpenSessionInViewFilter</filter-name>  <filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class></filter>


0 0
原创粉丝点击