Hibernate version: 3.1beta2
Can anyone clarify me how
FETCH ALL PROPERTIES should work
I added following test method to org.hibernate.test.instrument.InstrumentTest and it fails.
Code:
public void testRealFetchAll() throws Exception {
Session s = openSession();
Owner o = new Owner();
Document doc = new Document();
Folder fol = new Folder();
o.setName("gavin");
doc.setName("Hibernate in Action");
doc.setSummary("blah");
doc.updateText("blah blah");
fol.setName("books");
doc.setOwner(o);
doc.setFolder(fol);
fol.getDocuments().add(doc);
s.persist(o);
s.persist(fol);
s.flush();
s.clear();
doc = (Document) s.createQuery("from Document fetch all properties").uniqueResult();
assertTrue( Hibernate.isPropertyInitialized( doc, "folder" ) );// OK
assertEquals( doc.getSummary(), "blah" );
s.flush();
s.connection().commit();
s.close();
try {
doc.getFolder().getName();
} catch (LazyInitializationException e) {
fail ("LazyInitializationException should not be thown");//Failure
}
s = openSession();
s.delete(doc);
s.delete( doc.getFolder() );
s.delete( doc.getOwner() );
s.flush();
s.connection().commit();
s.close();
}
I was sured that
FETCH ALL PROPERTIES should initialize properties so they can be accessed outside session.