Hibernate4.X could not initialize proxy - no Session

could not initialize proxy - no Session

在web.xml中添加如下代码:

<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>

 

 

在hibernate.cfg.xml中添加如下代码:

<property name="hibernate.enable_lazy_load_no_trans">true</property>

 

猜你喜欢

转载自fengzhi714.iteye.com/blog/2211710
今日推荐