Hi,
I am new to hibernate. I am developing a flex application with java on the server side. I have a parent-child relation ship in my application domain objects. It is a wizard based UI where I'll bring all parents as a list on the first page (This happens in one HTTP service request aka BalzeDS service). Depending on the selection of a parent by the user (on clicking a parent), I would like to bring all children of the selected parent in a second HTTP service request. I am using lazy loading from parent to child. I am getting the following exception.
org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: com.sas.analytics.mfg.pam.domain.DataSelectionDefinition.dataSelectionSubjects, no session or session was closed
Following is my domain relationship.
<hibernate-mapping> <class name="test.parent" table="parent_table"> <id name="id"> <column name="ID" /> <generator class="native"/> </id> . . . <set name="childrenObjects" table="child_table" fetch="select" cascade="all-delete-orphan" inverse="true"> <key> <column name="ID" not-null="true" /> </key> <one-to-many class="test.child"/> </set> . . . </class> </hibernate-mapping>
<hibernate-mapping> <class name="test.child" table="child_table"> <id name="id"> <column name="CHILD_ID" /> <generator class="native"/> </id>
<many-to-one name="parentDefinition" class="test.parent" fetch="select"> <column name="PARENT_ID" not-null="true" /> </many-to-one> . . </class> </hibernate-mapping>
My question is how can we use lazy loading for a one-to-many relation across two HTTP servcie request where the parents get populated in one view(on first HTTP service request) and depending on the selection of an entry in the parent view an application loads the children on to a second view (in second HTTP service request).
|