Hi,
I am using Spring, Hibernate and Struts. Here is what I try to do:
3 persisted classes:
A --> (1-to-many) --> B --> (1-to-many)--> C
All with cascade="all"
In one Struts Action, I retrieve A and found that all B are retrieved automatically (I use A.getBs()). After which I put A into the request and forward to another Action.
In the second Action, I try to get C (using B.getCs()) but got error message:
-----------------------------------------------------------------------------
18.09.04 12:18:44 [http8080-Processor25] DEBUG org.springframework.orm.hibernate.SessionFactoryUt ils - Opening Hibernate session
18.09.04 12:18:44 [http8080-Processor25] DEBUG net.sf.hibernate.impl.SessionImpl - opened session
18.09.04 12:18:44 [http8080-Processor25] DEBUG org.springframework.transaction.support.Transactio nSynchronizationManager - Bound value [org.springframework.orm.hibernate.SessionHolder@16 8be1b] for key [net.sf.hibernate.impl.SessionFactoryImpl@39d072] to thread [http8080-Processor25]
18.09.04 12:18:44 [http8080-Processor25] DEBUG net.canal.core.action.BaseLookupAction - BaseAction: getLookupMapName( keyName = View )
18.09.04 12:18:44 [http8080-Processor25] DEBUG net.canal.core.action.BaseLookupAction - BaseAction: getLookupMapName( keyName = Prepare )
18.09.04 12:19:19 [http8080-Processor25] ERROR net.sf.hibernate.LazyInitializationException - Failed to lazily initialize a collection - no Session
net.sf.hibernate.LazyInitializationException: Failed to lazily initialize a collection - no Session
------------------------------------------------------------------------------
Does it mean that before forwarding to Action B, I need to retrieve C first ? I thought it should be transparent to me as the cascade is set to 'all' for these classes already.
What do I misunderstood ?
thanks in advance !


Reply With Quote