請教:OpenSessionInViewFilter配置使用問題

dzgwt2006發表於2007-03-06
我在web.xml中已經配置瞭如下:
[code]
<!--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>
[/code]

但是為什麼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配置如下:
[code]
<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" />
[/code]
[code]
<many-to-one
name="module"
column="MODULE_ID"
class="com.hl3000.dblogic.DAO.POJO.PermModuledefine"
/>
[/code]

參考:
http://blog.csdn.net/nimeimei/articles/480646.aspx

相關文章