Hi at all, I've a big problem with lazy initialization of hibernate collections
When I invoce this method in my DAO service
public void fullyLoadedRequest(Request request) throws HibernateException {
getHibernateTemplate().initialize(request.getParam eters());
getHibernateTemplate().initialize(request.getFinal Actions());
}
Spring throws this exception:
org.springframework.orm.hibernate3.HibernateSystem Exception: disconnected session; nested exception is org.hibernate.HibernateException: disconnected session
I think that the problem is due to different session used to load and to lazy initialize the Request object.... but how could I change this Spring behavior?
I've configured Spring in this way:
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSes sionFactoryBean">
<property name="configLocation">
<value>classpath:etc/hibernate/hibernate.cfg.xml</value>
</property>
</bean>
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.Hibernat eTransactionManager"
>
<property name="sessionFactory">
<ref local="sessionFactory"/>
</property>
</bean>
<bean id="TransactionBean"
class="org.springframework.transaction.interceptor .TransactionProxyFactoryBean"
abstract="true">
<property name="transactionManager">
<ref local="transactionManager"/>
</property>
<property name="transactionAttributes">
<props>
<prop key="login*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="load*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>
....
<bean id="RequestTarget"
class="it.finmatica.reporservice.service.hibernate .HTRequestService">
<property name="sessionFactory">
<ref local="sessionFactory"/>
</property>
</bean>
<bean id="Request" parent="TransactionBean">
<property name="target">
<ref local="RequestTarget"/>
</property>
</bean>


Reply With Quote