I wired-up but it did not work as I expected. I have set the lazy inialization true between entities abd believe,HibernateInterceptor manages the hibernate session. When I trying to access the object properties, it thorws exception LazyInitializationException.
Error messgae : Transaction could not initialize proxy - the owning Session was closed
Stack Trace: org.hibernate.LazyInitializationException: could not initialize proxy - the owning Session was closed
at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:56)
at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:98)
at org.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializer.java:158)
configuration xml
<!-- THE HIBERNATE INTERCEPTOR -->
<bean id="hibernateInterceptor" class="org.springframework.orm.hibernate3.HibernateInterceptor">
<property name="sessionFactory" ref="app:sessionFactory" />
</bean>
<!-- Start Transaction proxy definition -->
<bean id="app:appTransactionProxy"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"
abstract="true">
<property name="transactionManager" ref="app:transactionManager" />
<property name="transactionAttributes">
<props>
<prop key="process*">PROPAGATION_REQUIRED,readOnly,
-Exception,-RuntimeException</prop>
<prop key="submit*">PROPAGATION_REQUIRED,readOnly,
-Exception,-RuntimeException</prop>
<prop key="*">PROPAGATION_REQUIRED,readOnly,
-Exception,-RuntimeException</prop>
</props>
</property>
<property name="preInterceptors">
<list>
<ref bean="hibernateInterceptor" />
</list>
</property>
<property name="postInterceptors">
<list>
<ref bean="hibernateInterceptor" />
</list>
</property>
</bean>
<bean id="app:daoTransactionProxy"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"
abstract="true">
<property name="transactionManager" ref="app:transactionManager" />
<property name="transactionAttributes">
<props>
<prop key="unlock*">PROPAGATION_REQUIRES_NEW,
-Exception,-RuntimeException</prop>
<prop key="getHead*">PROPAGATION_REQUIRES_NEW,
-Exception,-RuntimeException</prop>
<prop key="remove*">PROPAGATION_REQUIRES_NEW,
-Exception,-RuntimeException</prop>
<prop key="create*">PROPAGATION_REQUIRES_NEW,
-Exception,-RuntimeException</prop>
<prop key="update*">PROPAGATION_REQUIRES_NEW,
-Exception,-RuntimeException</prop>
<prop key="addTail*">PROPAGATION_REQUIRES_NEW,
-Exception,-RuntimeException</prop>
<prop key="checkForTimeouts">PROPAGATION_REQUIRED,
-Exception,-RuntimeException</prop>
<prop key="breakOldLocks">PROPAGATION_REQUIRES_NEW,
-Exception,-RuntimeException</prop>
<prop key="find*">PROPAGATION_REQUIRES_NEW,readOnly,
-Exception,-RuntimeException</prop>
<prop key="load*">PROPAGATION_REQUIRES_NEW,readOnly,
-Exception,-RuntimeException</prop>
<prop key="*">PROPAGATION_REQUIRED,readOnly,
-Exception,-RuntimeException</prop>
</props>
</property>
<property name="preInterceptors">
<list>
<ref bean="hibernateInterceptor" />
</list>
</property>
<property name="postInterceptors">
<list>
<ref bean="hibernateInterceptor" />
</list>
</property>
</bean>
<bean id="app:transactionManager" name="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="app:sessionFactory" />
<property name="nestedTransactionAllowed" value="true" />
</bean>
<bean id="app:sessionFactory" name="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="app:dataSource" />
<property name="mappingResources">
<list>
<value>com/app/domain/app.hbm.xml</value>
<value>com/common/domain/shared.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
${app.hibernate.dialect}
</prop>
<prop key="hibernate.show_sql">false</prop>
<prop key="hibernate.generate_statistics">false</prop>
</props>
</property>
<property name="eventListeners">
<map>
<entry key="merge">
<bean
class="org.springframework.orm.hibernate3.support.IdTransferringMergeEventListener" />
</entry>
</map>
</property>
</bean>
<!--Start DATA SOURCE -->
<bean id="app:dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
destroy-method="close">
<!-- Config values-->
</bean>
Any input on this ?