Here's the solution I think...
I created the following HQL
Code:
private static final String retrieveDeepConversation ="from com.recorder.http.Conversation as c " +
"left join fetch c.messages message " +
"left join fetch message.parameters " +
"left join fetch message.headers " +
"left join fetch message.response res " +
"left join fetch res.parameters " +
"left join fetch res.headers " +
"where c.conversationId=? " ;
and as the Overflow entity is a member of both the
request and response objects,I set the lazy attribute of the Overflow class mapping definition to be false so that it is loaded straight away.
Code:
<class name="com.recorder.http.attribute.Overflow" table="OVERFLOW" lazy="false">
Is there a similar setting for association sets?
Ultimately i was hoping to have a one-to-one association between
the Request and the Response which would allow Requests to have null Responses.
And then have a one-to-one association from Response to Request where the association could not be null.
i.e. Requests could have zero or one responses but
responses had to have request.
The current mapping I have for these associations is as follows...
Code:
<subclass name="com.recorder.http.Request" discriminator-value="R">
<property name="requestLine"/>
<many-to-one name="response"
column="id"
cascade="save-update,delete"
unique="true"
lazy="false"
not-null="false"/>
</subclass>
<subclass name="com.recorder.http.Response" discriminator-value="S">
<property name="statusLine"/>
<one-to-one name="request" property-ref="response"/>
</subclass>
This allows for the request to associate with the response but saving the
response object doesn't set the id column to the primary key of the request.
Any ideas? I guess I'm haveing problems because the two classes are
subclasses of the same class and hence operate on the same table.
Thanks,
Mark.