异常:could not initialize proxy - no Session

上周在编写hibernate4的相关代码的时候,出现异常 org.hibernate.LazyInitializationException: could not

initialize proxy - no Session  网上出现最多的解决方案是  openSessionInViewFilter

        形如:

<!-- open session filter -->
    <filter>
        <filter-name>openSessionInViewFilter</filter-name>
        <filter-class>org.springframework.orm.hibernate4.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>

<session-factory>
<property name="hibernate.enable_lazy_load_no_trans">true</property>

</session-factory>

你可能感兴趣的:(session)