public class TestFetchAllExecutable extends AbstractExecutable { public void execute() { 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); s.persist(o); s.persist(fol); t.commit(); s.close(); s = getFactory().openSession(); t = s.beginTransaction(); doc = (Document) s.createQuery("from Document fetch all properties").uniqueResult(); Assert.assertTrue( Hibernate.isPropertyInitialized( doc, "summary" ) ); Assert.assertTrue( Hibernate.isPropertyInitialized( doc, "upperCaseName" ) ); Assert.assertTrue( Hibernate.isPropertyInitialized( doc, "owner" ) ); Assert.assertEquals( doc.getSummary(), "blah" ); s.delete(doc); s.delete( doc.getOwner() ); s.delete( doc.getFolder() ); t.commit(); s.close()
public class TestIsPropertyInitializedExecutable extends AbstractExecutable { public void execute() { 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()
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/instrument/cases/TestFetchAllExecutable.java File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/instrument/cases/TestIsPropertyInitializedExecutable.java
Method name: Method name:
Number of AST nodes: 0 Number of AST nodes: 0
1
public class TestFetchAllExecutable extends AbstractExecutable {
1
public class TestIsPropertyInitializedExecutable extends AbstractExecutable {
2
	public void execute() {
2
	public void execute() {
3
		Session s = getFactory().openSession();
3
		Session s = getFactory().openSession();
4
		Transaction t = s.beginTransaction();
4
		Transaction t = s.beginTransaction();
5
		Owner o = new Owner();
5
		Owner o = new Owner();
6
		Document doc = new Document();
6
		Document doc = new Document();
7
		Folder fol = new Folder();
7
		Folder fol = new Folder();
8
		o.setName("gavin");
8
		o.setName("gavin");
9
		doc.setName("Hibernate in Action");
9
		doc.setName("Hibernate in Action");
10
		doc.setSummary("blah");
10
		doc.setSummary("blah");
11
		doc.updateText("blah blah");
11
		doc.updateText("blah blah");
12
		fol.setName("books");
12
		fol.setName("books");
13
		doc.setOwner(o);
13
		doc.setOwner(o);
14
		doc.setFolder(fol);
14
		doc.setFolder(fol);
15
		fol.getDocuments().add(doc);
15
		fol.getDocuments().add(doc);
16
		
16
		Assert.assertTrue( Hibernate.isPropertyInitialized( doc, "summary" ) );
17
s.persist(o);
17
		s.persist(o);
18
		s.persist(fol);
18
		s.persist(fol);
19
		t.commit();
19
		t.commit();
20
		s.close();
20
		s.close();
21
		s = getFactory().openSession();
21
		s = getFactory().openSession();
22
		t = s.beginTransaction();
22
		t = s.beginTransaction();
23
		doc = (Document) s.createQuery("from Document fetch all properties").uniqueResult();
23
		doc = (Document) s.get( Document.class, doc.getId() );
24
		Assert.assertTrue( Hibernate.isPropertyInitialized( doc, "summary" ) );
24
		Assert.assertFalse( Hibernate.isPropertyInitialized( doc, "summary" ) );
25
		Assert.assertTrue( Hibernate.isPropertyInitialized( doc, "upperCaseName" ) );
25
		Assert.assertFalse( Hibernate.isPropertyInitialized( doc, "upperCaseName" ) );
26
		Assert.assertTrue( Hibernate.isPropertyInitialized( doc, "owner" ) );
26
		Assert.assertFalse( Hibernate.isPropertyInitialized( doc, "owner" ) );
27
		Assert.assertEquals( doc.getSummary(), "blah" );
27
		
28
		s.delete(doc);
28
s.delete(doc);
29
		s.delete( doc.getOwner() );
29
		s.delete( doc.getOwner() );
30
		s.delete( doc.getFolder() );
30
		s.delete( doc.getFolder() );
31
		t.commit();
31
		t.commit();
32
		s.close()
32
		s.close()
Summary
Number of common nesting structure subtrees0
Number of refactorable cases0
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)0.0
Clones location
Number of node comparisons0