2
package org.hibernate.test.instrument.cases;
4
import org.hibernate.Session;
5
import org.hibernate.Transaction;
6
import org.hibernate.Hibernate;
7
import org.hibernate.test.instrument.domain.Owner;
8
import org.hibernate.test.instrument.domain.Document;
9
import org.hibernate.test.instrument.domain.Folder;
10
import junit.framework.Assert;
13
* @author Steve Ebersole
15
public class TestIsPropertyInitializedExecutable extends AbstractExecutable {
16
public void execute() {
17
Session s = getFactory().openSession();
18
Transaction t = s.beginTransaction();
19
Owner o = new Owner();
20
Document doc = new Document();
21
Folder fol = new Folder();
23
doc.setName("Hibernate in Action");
24
doc.setSummary("blah");
25
doc.updateText("blah blah");
29
fol.getDocuments().add(doc);
30
Assert.assertTrue( Hibernate.isPropertyInitialized( doc, "summary" ) );
36
s = getFactory().openSession();
37
t = s.beginTransaction();
38
doc = (Document) s.get( Document.class, doc.getId() );
39
Assert.assertFalse( Hibernate.isPropertyInitialized( doc, "summary" ) );
40
Assert.assertFalse( Hibernate.isPropertyInitialized( doc, "upperCaseName" ) );
41
Assert.assertFalse( Hibernate.isPropertyInitialized( doc, "owner" ) );
43
s.delete( doc.getOwner() );
44
s.delete( doc.getFolder() );