论坛首页 入门技术论坛

请教:OpenSessionInViewFilter配置使用问题

浏览 4267 次
该帖已经被评为新手帖
作者 正文
   发表时间:2007-03-06  
我在web.xml中已经配置了如下:
<!--OpenSessionInViewFilter配置-->
    <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>
    </filter>
    <filter-mapping> 
        <filter-name>OpenSessionInViewFilter</filter-name> 
        <url-pattern>/*</url-pattern> 
    </filter-mapping>


但是为什么hibernate配置lazy="true" 的时候,还是提示:
2007-03-06 10:34:52,562 ERROR [org.hibernate.LazyInitializationException] - failed to lazily initialize a collection of role: com.hl3000.dblogic.DAO.POJO.PermModuledefine.permissions - no session or session was closed
org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: com.hl3000.dblogic.DAO.POJO.PermModuledefine.permissions - no session or session was closed


是我的那里配置还没弄好么? 

hibernate配置如下:
<set 
        name="permissions"
        inverse="true"
        lazy="true" 
        order-by="PERMISSION_ID">
        
        <key column="MODULE_ID" />
        <one-to-many class="com.hl3000.dblogic.DAO.POJO.PermPermissiondefine" />

<many-to-one
	        name="module"
	        column="MODULE_ID"
	        class="com.hl3000.dblogic.DAO.POJO.PermModuledefine"  
       />


参考:
http://blog.csdn.net/nimeimei/articles/480646.aspx
   发表时间:2007-03-06  
解决方法:
struts-config.xml
  <plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
    <set-property property="contextConfigLocation" value="/WEB-INF/applicationContext_action.xml" />
  </plug-in>

注意:这里只有applicationContext_action.xml

web.xml
	<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>/WEB-INF/applicationContext*.xml</param-value>
	</context-param>
.........
	<filter>
		<filter-name>OpenSessionInViewFilter</filter-name>
		<filter-class>
			org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
		</filter-class>
	</filter>

	<filter-mapping>
		<filter-name>OpenSessionInViewFilter</filter-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping>
0 请登录后投票
论坛首页 入门技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics