public void testInitFromCache() { if ( !isRunnable() ) { reportSkip( "classes not instrumented", "instrumentation tests" ); return; } Session s; Transaction tx; s = getSessions().openSession(); tx = s.beginTransaction(); s.persist( new Document("HiA", "Hibernate book", "Hibernate is....") ); tx.commit(); s.close(); s = getSessions().openSession(); tx = s.beginTransaction(); s.createQuery("from Document fetch all properties").uniqueResult(); tx.commit(); s.close(); getSessions().getStatistics().clear(); s = getSessions().openSession(); tx = s.beginTransaction(); Document d = (Document) s.createCriteria(Document.class).uniqueResult(); assertFalse( Hibernate.isPropertyInitialized(d, "text") ); assertFalse( Hibernate.isPropertyInitialized(d, "summary") ); assertEquals( "Hibernate is....", d.getText() ); assertTrue( Hibernate.isPropertyInitialized(d, "text") ); assertTrue( Hibernate.isPropertyInitialized(d, "summary") ); tx.commit(); s.close(); assertEquals( 2, getSessions().getStatistics().getPrepareStatementCount() ); s = getSessions().openSession(); tx = s.beginTransaction(); d = (Document) s.get(Document.class, d.getId()); assertFalse( Hibernate.isPropertyInitialized(d, "text") ); assertFalse( Hibernate.isPropertyInitialized(d, "summary") ); tx.commit(); s.close();
public void testInitFromCache2() { if ( !isRunnable() ) { reportSkip( "classes not instrumented", "instrumentation tests" ); return; } Session s; Transaction tx; s = getSessions().openSession(); tx = s.beginTransaction(); s.persist( new Document("HiA", "Hibernate book", "Hibernate is....") ); tx.commit(); s.close(); s = getSessions().openSession(); tx = s.beginTransaction(); s.createQuery("from Document fetch all properties").uniqueResult(); tx.commit(); s.close(); getSessions().getStatistics().clear(); s = getSessions().openSession(); tx = s.beginTransaction(); Document d = (Document) s.createCriteria(Document.class).uniqueResult(); assertFalse( Hibernate.isPropertyInitialized(d, "text") ); assertFalse( Hibernate.isPropertyInitialized(d, "summary") ); assertEquals( "Hibernate is....", d.getText() ); assertTrue( Hibernate.isPropertyInitialized(d, "text") ); assertTrue( Hibernate.isPropertyInitialized(d, "summary") ); tx.commit(); s.close(); assertEquals( 1, getSessions().getStatistics().getPrepareStatementCount() ); s = getSessions().openSession(); tx = s.beginTransaction(); d = (Document) s.get(Document.class, d.getId()); assertTrue( Hibernate.isPropertyInitialized(d, "text") ); assertTrue( Hibernate.isPropertyInitialized(d, "summary") ); tx.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/lazycache/InstrumentCacheTest.java File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/lazycache/InstrumentCacheTest.java
Method name: Method name:
Number of AST nodes: 0 Number of AST nodes: 0
1
public void testInitFromCache() {
1
public void testInitFromCache2() {
2
		if ( !isRunnable() ) {
2
		if ( !isRunnable() ) {
3
			reportSkip( "classes not instrumented", "instrumentation tests" );
3
			reportSkip( "classes not instrumented", "instrumentation tests" );
4
			return;
4
			return;
5
		}
5
		}
6
		Session s;
6
		Session s;
7
		Transaction tx;
7
		Transaction tx;
8
		s = getSessions().openSession();
8
		s = getSessions().openSession();
9
		tx = s.beginTransaction();
9
		tx = s.beginTransaction();
10
		s.persist( new Document("HiA", "Hibernate book", "Hibernate is....") );
10
		s.persist( new Document("HiA", "Hibernate book", "Hibernate is....") );
11
		tx.commit();
11
		tx.commit();
12
		s.close();
12
		s.close();
13
		s = getSessions().openSession();
13
		s = getSessions().openSession();
14
		tx = s.beginTransaction();
14
		tx = s.beginTransaction();
15
		s.createQuery("from Document fetch all properties").uniqueResult();
15
		s.createQuery("from Document fetch all properties").uniqueResult();
16
		tx.commit();
16
		tx.commit();
17
		s.close();
17
		s.close();
18
		getSessions().getStatistics().clear();
18
		getSessions().getStatistics().clear();
19
		s = getSessions().openSession();
19
		s = getSessions().openSession();
20
		tx = s.beginTransaction();
20
		tx = s.beginTransaction();
21
		Document d = (Document) s.createCriteria(Document.class).uniqueResult();
21
		Document d = (Document) s.createCriteria(Document.class).uniqueResult();
22
		assertFalse( Hibernate.isPropertyInitialized(d, "text") );
22
		assertFalse( Hibernate.isPropertyInitialized(d, "text") );
23
		assertFalse( Hibernate.isPropertyInitialized(d, "summary") );
23
		assertFalse( Hibernate.isPropertyInitialized(d, "summary") );
24
		assertEquals( "Hibernate is....", d.getText() );
24
		assertEquals( "Hibernate is....", d.getText() );
25
		assertTrue( Hibernate.isPropertyInitialized(d, "text") );
25
		assertTrue( Hibernate.isPropertyInitialized(d, "text") );
26
		assertTrue( Hibernate.isPropertyInitialized(d, "summary") );
26
		assertTrue( Hibernate.isPropertyInitialized(d, "summary") );
27
		tx.commit();
27
		tx.commit();
28
		s.close();
28
		s.close();
29
		assertEquals( 2, getSessions().getStatistics().getPrepareStatementCount() );
29
		assertEquals( 1, getSessions().getStatistics().getPrepareStatementCount() );
30
		s = getSessions().openSession();
30
		s = getSessions().openSession();
31
		tx = s.beginTransaction();
31
		tx = s.beginTransaction();
32
		d = (Document) s.get(Document.class, d.getId());
32
		d = (Document) s.get(Document.class, d.getId());
33
		assertFalse( Hibernate.isPropertyInitialized(d, "text") );
33
		assertTrue( Hibernate.isPropertyInitialized(d, "text") );
34
		assertFalse( Hibernate.isPropertyInitialized(d, "summary") );
34
		assertTrue( Hibernate.isPropertyInitialized(d, "summary") );
35
		tx.commit();
35
		tx.commit();
36
		s.close();
36
		s.close();
37
	
37
	
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