FileDocCategorySizeDatePackage
TestIsPropertyInitializedExecutable.javaAPI DocHibernate 3.2.51501Tue Dec 12 16:22:26 GMT 2006org.hibernate.test.instrument.cases

TestIsPropertyInitializedExecutable

public class TestIsPropertyInitializedExecutable extends AbstractExecutable
author
Steve Ebersole

Fields Summary
Constructors Summary
Methods Summary
public voidexecute()

		Session s = getFactory().openSession();
		Transaction t = s.beginTransaction();
		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);
		Assert.assertTrue( Hibernate.isPropertyInitialized( doc, "summary" ) );
		s.persist(o);
		s.persist(fol);
		t.commit();
		s.close();

		s = getFactory().openSession();
		t = s.beginTransaction();
		doc = (Document) s.get( Document.class, doc.getId() );
		Assert.assertFalse( Hibernate.isPropertyInitialized( doc, "summary" ) );
		Assert.assertFalse( Hibernate.isPropertyInitialized( doc, "upperCaseName" ) );
		Assert.assertFalse( Hibernate.isPropertyInitialized( doc, "owner" ) );
		s.delete(doc);
		s.delete( doc.getOwner() );
		s.delete( doc.getFolder() );
		t.commit();
		s.close();