anthony wrote:
i've run other tests with lazy properties, it works for me too
OK, I found "instrument" test case that I think is supposed to test lazy loading of a property. In the mapping file that comes with HB test case the "name" property is not lazy loaded. The "summary" is. So my understanding is that when you load the object the summary property should not be in the first SELECT on the object. So either the instrumentation failed or there's some other kind of a problem, but the bottom line is that even though the test case doesn't fail the property is
not lazily loaded. Or I'm messing something up.
UPDATED TEST CASE
s = openSession();
doc = (Document) s.createQuery("from Document").uniqueResult();
System.out.println("*** got doc = ");
doc.getName();
System.out.println("** got name = " + doc.getName());
assertEquals( doc.getText(), "blah blah" );
System.out.println("** got text = " + doc.getText());
assertEquals( doc.getSummary(), "blah" );
System.out.println("** summary = " + doc.getSummary());
s.connection().commit();
s.close();
DEBUG OUTPUT
16:07:13,085 DEBUG SQL:292 - select document0_.id as id, document0_.name as name2_, document0_.folder as folder2_ from documents document0_
*** got doc =
** got name = Hibernate in Action
16:07:13,596 DEBUG SQL:292 - select document_.summary as summary2_, document_.owner as owner2_, document_.text as text2_, document_.lastTextModification as lastText7_2_, upper(document_.name) as formula0_ from documents document_ where document_.id=?
16:07:13,907 DEBUG SQL:292 - select owner0_.id as id0_, owner0_.name as name1_0_ from owners owner0_ where owner0_.id=?
** got text = blah blah
** summary = blah