Sorry about the mispost; this should allow you to read the examples I provided. Unfortunately, I'm having trouble posting my example without the text vanishing, os please bear with me:
Hi there. I'm using Hibernate with Spring and JBoss, and am having problems with lazy loading. I'm using XDoclet to generate my Hibernate configuration files, and have searched on this topic extensively. The best resource so far that I have found is here: http://www.jroller.com/page/kbaum/20040708 an interesting entry is: http://www-128.ibm.com/developerworks/java/library/j-hibern/ This describes how to implement lazy loading in the business layer. When I implement, however, I still get a LazyLoadingException (config files below): @[EMAIL PROTECTED] 23484 ERROR [AWT-EventQueue-0] LazyInitializationException.<init>(25) | Failed to lazily initialize a collection - no session or session was closed net.sf.hibernate.LazyInitializationException: Failed to lazily initialize a collection - no session or session was closed at net.sf.hibernate.collection.PersistentCollection.initialize(PersistentCollection.java:209) at net.sf.hibernate.collection.PersistentCollection.read(PersistentCollection.java:71) at net.sf.hibernate.collection.Bag.iterator(Bag.java:256) I have also tried using the OpenSessionInViewInterceptor and OpenSessionInViewFilter. However, because data objects are accessed using a manager class which accesses the DAO class, I didn't have high expectations of that method's working. In our Hibernate application context, we have: <!-- Transaction manager for a single Hibernate SessionFactory (alternative to JTA) --> <bean id="transactionManager" class="org.springframework.orm.hibernate.HibernateTransactionManager"> <property name="sessionFactory"><ref local="sessionFactory"/></property> </bean> along with DAO implementation beans, like so: <!-- UserDAO: Hibernate implementation --> <bean id="userDAO" class="com.adaptiverfid.dao.hibernate.UserDAOHibernate"> <property name="sessionFactory"><ref local="sessionFactory"/></property> </bean> We have a "service" application context, wherein is: <bean id="hibernateInterceptor" class="org.springframework.orm.hibernate.HibernateInterceptor"> <property name="sessionFactory"> <ref bean="sessionFactory"/> </property> </bean> <bean id="shipmentManagerObj" parent="txProxyTemplate"> <property name="target"> <bean class="com.adaptiverfid.service.impl.ShipmentManagerImpl"> <property name="shipmentDAO"><ref bean="shipmentDAO"/></property> </bean> </property> <property name="transactionAttributes"> <props> <prop key="save*">PROPAGATION_REQUIRED</prop> <prop key="update*">PROPAGATION_REQUIRED</prop> <prop key="remove*">PROPAGATION_REQUIRED</prop> <prop key="create*">PROPAGATION_REQUIRED</prop> <prop key="print*">PROPAGATION_REQUIRED</prop> <prop key="finish*">PROPAGATION_REQUIRED</prop> <prop key="validate*">PROPAGATION_REQUIRED</prop> <prop key="get*">PROPAGATION_REQUIRED</prop> <prop key="*">PROPAGATION_REQUIRED,readOnly</prop> </props> </property> <property name="preInterceptors"> <list> <ref bean="shipmentStatusChangeWatcher"/> //I've tried putting a reference to the hibernateInterceptor here. That doesn't help. </list> </property> </bean> <bean id="shipmentManager" class="org.springframework.aop.framework.ProxyFactoryBean"> <property name="proxyTarget"><ref bean="shipmentManagerObj"/></property> <property name="proxyInterfaces"> <value>com.adaptiverfid.service.ShipmentManager</value> </property> <property name="interceptorNames"> <list> <value>hibernateInterceptor</value> </list> </property> </bean> Any help is appreciated. Thanks. Richard View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3914505#3914505 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3914505 ------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click _______________________________________________ JBoss-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/jboss-user
