I try to convert my hbm.xml to annotation, and I have one problem.
Here's my definition:
<class name="FirmUser" lazy="false"> ... </class>
<class name="Interview"> <many-to-one name="firmUser" column="firm_user_id" class="FirmUser" lazy="no-proxy"/> ... </class>
And here's how I retrieve an Interview instance
Interview interview = (Interview)session.load(Interview.class, interviewId); interview.getFirmUser();
I closed the session after the above code segment, and all fields of FirmUser have been retrieved.
But when I switch to Annotation, I got a
could not initialize proxy - the owning Session was closed
error on one of the property of FirmUser
and I can see from hibernate generated sql, it didn't make a query to FirmUser table, while it suppose to do it cos I explicitly called getFirmUser() while session was opened.
And I'v noticed that same thing happend when I use a hbm.xml file but
with lazy="true" in the class FirmUser attibute.
So, is their any way in Annotation to set the whole class to eager retrieval?
|