I tried adding lazy="true" to the associating, but still to no avail. Here's some simple code I put together to reduce it to its most simple form.
Code:
try {
SessionFactory factory = (SessionFactory)InitialContextFactory.getInitialContext().lookup("java:/jobwired/HibernateFactory");
Session session = factory.getCurrentSession();
List l = session.createCriteria(InterviewImpl.class).list();
Iterator it = l.iterator();
while (it.hasNext()) {
InterviewImpl interview = (InterviewImpl)it.next();
System.out.println(interview.getInterviewerName());
}
} catch (Exception e) {
e.printStackTrace();
}
getInterviewerName simple returns a string property that is stored in the INTERVIEW table. And here is the output when called... As you can see it's still eagerly fetching.
Code:
13:48:49,888 INFO [STDOUT] Hibernate: select this_.oid as oid0_, this_.APPLICATION_OID as APPLICAT2_262_0_, this_.ORG_PRINCIPAL_OID as ORG3_262_0_, this_.LOCATION_OID as LOCATION4_262_0_, this_.INTERVIEW_DATE as INTERVIEW5_262_0_, this_.NOTES as NOTES262_0_, this_.TYPE as TYPE262_0_, this_.RATING as RATING262_0_, this_.INTERVIEWER as INTERVIE9_262_0_, this_.INTERVIEW_ID as INTERVIEW10_262_0_, this_.INTERVIEWER_NAME as INTERVI11_262_0_, this_.FEEDBACK_RECEIVED as FEEDBACK12_262_0_, this_.FEEDBACK_REQUEST_SENT as FEEDBACK13_262_0_, this_.INVITE_SENT as INVITE14_262_0_, this_.REMINDER_SENT as REMINDER15_262_0_, this_.LOCATION_DETAILS as LOCATION16_262_0_, this_.CANDIDATE_NAME as CANDIDATE17_262_0_, this_.POSITION_TITLE as POSITION18_262_0_ from INTERVIEW this_
13:48:50,817 INFO [STDOUT] Hibernate: select applicatio0_.oid as oid0_, applicatio0_.EXAM_SESSION_OID as EXAM2_258_0_, applicatio0_.POSITION_OPENING_OID as POSITION3_258_0_, applicatio0_.SOURCE_POSITION_OPENING_OID as SOURCE4_258_0_, applicatio0_.PROFILE_OID as PROFILE5_258_0_, applicatio0_.COMPANY_OID as COMPANY6_258_0_, applicatio0_.START_TIME as START7_258_0_, applicatio0_.SUBMIT_TIME as SUBMIT8_258_0_, applicatio0_.EXAM_COMPLETE as EXAM9_258_0_, applicatio0_.SUBMITTED as SUBMITTED258_0_ from APPLICATION applicatio0_ where applicatio0_.oid=?
13:48:50,857 INFO [STDOUT] Hibernate: select applicatio0_.oid as oid0_, applicatio0_.EXAM_SESSION_OID as EXAM2_258_0_, applicatio0_.POSITION_OPENING_OID as POSITION3_258_0_, applicatio0_.SOURCE_POSITION_OPENING_OID as SOURCE4_258_0_, applicatio0_.PROFILE_OID as PROFILE5_258_0_, applicatio0_.COMPANY_OID as COMPANY6_258_0_, applicatio0_.START_TIME as START7_258_0_, applicatio0_.SUBMIT_TIME as SUBMIT8_258_0_, applicatio0_.EXAM_COMPLETE as EXAM9_258_0_, applicatio0_.SUBMITTED as SUBMITTED258_0_ from APPLICATION applicatio0_ where applicatio0_.oid=?
13:48:50,867 INFO [STDOUT] Hibernate: select applicatio0_.oid as oid0_, applicatio0_.EXAM_SESSION_OID as EXAM2_258_0_, applicatio0_.POSITION_OPENING_OID as POSITION3_258_0_, applicatio0_.SOURCE_POSITION_OPENING_OID as SOURCE4_258_0_, applicatio0_.PROFILE_OID as PROFILE5_258_0_, applicatio0_.COMPANY_OID as COMPANY6_258_0_, applicatio0_.START_TIME as START7_258_0_, applicatio0_.SUBMIT_TIME as SUBMIT8_258_0_, applicatio0_.EXAM_COMPLETE as EXAM9_258_0_, applicatio0_.SUBMITTED as SUBMITTED258_0_ from APPLICATION applicatio0_ where applicatio0_.oid=?
13:48:51,047 INFO [STDOUT] Hibernate: select applicatio0_.oid as oid0_, applicatio0_.EXAM_SESSION_OID as EXAM2_258_0_, applicatio0_.POSITION_OPENING_OID as POSITION3_258_0_, applicatio0_.SOURCE_POSITION_OPENING_OID as SOURCE4_258_0_, applicatio0_.PROFILE_OID as PROFILE5_258_0_, applicatio0_.COMPANY_OID as COMPANY6_258_0_, applicatio0_.START_TIME as START7_258_0_, applicatio0_.SUBMIT_TIME as SUBMIT8_258_0_, applicatio0_.EXAM_COMPLETE as EXAM9_258_0_, applicatio0_.SUBMITTED as SUBMITTED258_0_ from APPLICATION applicatio0_ where applicatio0_.oid=?
13:48:51,796 INFO [STDOUT] Hibernate: select applicatio0_.oid as oid0_, applicatio0_.EXAM_SESSION_OID as EXAM2_258_0_, applicatio0_.POSITION_OPENING_OID as POSITION3_258_0_, applicatio0_.SOURCE_POSITION_OPENING_OID as SOURCE4_258_0_, applicatio0_.PROFILE_OID as PROFILE5_258_0_, applicatio0_.COMPANY_OID as COMPANY6_258_0_, applicatio0_.START_TIME as START7_258_0_, applicatio0_.SUBMIT_TIME as SUBMIT8_258_0_, applicatio0_.EXAM_COMPLETE as EXAM9_258_0_, applicatio0_.SUBMITTED as SUBMITTED258_0_ from APPLICATION applicatio0_ where applicatio0_.oid=?