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();
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();
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: void testInitFromCache2() Method name: void testInitFromCache()
Number of AST nodes: 34 Number of AST nodes: 34
1
if ( !isRunnable() ) {
1
if ( !isRunnable() ) {
2
			reportSkip( "classes not instrumented", "instrumentation tests" );
2
			reportSkip( "classes not instrumented", "instrumentation tests" );
3
			return;
3
			return;
4
		}
4
		}
5
		Session s;
5
		Session s;
6
		Transaction tx;
6
		Transaction tx;
7
		s = getSessions().openSession();
7
		s = getSessions().openSession();
8
		tx = s.beginTransaction();
8
		tx = s.beginTransaction();
9
		s.persist( new Document("HiA", "Hibernate book", "Hibernate is....") );
9
		s.persist( new Document("HiA", "Hibernate book", "Hibernate is....") );
10
		tx.commit();
10
		tx.commit();
11
		s.close();
11
		s.close();
12
		s = getSessions().openSession();
12
		s = getSessions().openSession();
13
		tx = s.beginTransaction();
13
		tx = s.beginTransaction();
14
		s.createQuery("from Document fetch all properties").uniqueResult();
14
		s.createQuery("from Document fetch all properties").uniqueResult();
15
		tx.commit();
15
		tx.commit();
16
		s.close();
16
		s.close();
17
		getSessions().getStatistics().clear();
17
		getSessions().getStatistics().clear();
18
		s = getSessions().openSession();
18
		s = getSessions().openSession();
19
		tx = s.beginTransaction();
19
		tx = s.beginTransaction();
20
		Document d = (Document) s.createCriteria(Document.class).uniqueResult();
20
		Document d = (Document) s.createCriteria(Document.class).uniqueResult();
21
		assertFalse( Hibernate.isPropertyInitialized(d, "text") );
21
		assertFalse( Hibernate.isPropertyInitialized(d, "text") );
22
		assertFalse( Hibernate.isPropertyInitialized(d, "summary") );
22
		assertFalse( Hibernate.isPropertyInitialized(d, "summary") );
23
		assertEquals( "Hibernate is....", d.getText() );
23
		assertEquals( "Hibernate is....", d.getText() );
24
		assertTrue( Hibernate.isPropertyInitialized(d, "text") );
24
		assertTrue( Hibernate.isPropertyInitialized(d, "text") );
25
		assertTrue( Hibernate.isPropertyInitialized(d, "summary") );
25
		assertTrue( Hibernate.isPropertyInitialized(d, "summary") );
26
		tx.commit();
26
		tx.commit();
27
		s.close();
27
		s.close();
28
		assertEquals( 1, getSessions().getStatistics().getPrepareStatementCount() );
28
		assertEquals( 2, getSessions().getStatistics().getPrepareStatementCount() );
29
		s = getSessions().openSession();
29
		s = getSessions().openSession();
30
		tx = s.beginTransaction();
30
		tx = s.beginTransaction();
31
		d = (Document) s.get(Document.class, d.getId());
31
		d = (Document) s.get(Document.class, d.getId());
32
		assertTrue( Hibernate.isPropertyInitialized(d, "text") );
32
		assertFalse( Hibernate.isPropertyInitialized(d, "text") );
33
		assertTrue( Hibernate.isPropertyInitialized(d, "summary") );
33
		assertFalse( Hibernate.isPropertyInitialized(d, "summary") );
34
		tx.commit();
34
		tx.commit();
35
		s.close();
35
		s.close();
Summary
Number of common nesting structure subtrees1
Number of refactorable cases0
Number of non-refactorable cases1
Time elapsed for finding largest common nesting structure subtrees (ms)0.1
Clones locationClones are declared in the same class
Number of node comparisons278
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements34
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)27.1
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    if (!isRunnable())
    1
    if (!isRunnable())
    2
    reportSkip("classes not instrumented", "instrumentation tests");
    2
    reportSkip("classes not instrumented", "instrumentation tests");
    3
    return;
    3
    return;
    4
    Session s;
    4
    Session s;
    5
    Transaction tx;
    5
    Transaction tx;
    6
    s = getSessions().openSession();
    6
    s = getSessions().openSession();
    7
    tx = s.beginTransaction();
    7
    tx = s.beginTransaction();
    8
    s.persist(new Document("HiA", "Hibernate book", "Hibernate is...."));
    8
    s.persist(new Document("HiA", "Hibernate book", "Hibernate is...."));
    9
    tx.commit();
    9
    tx.commit();
    10
    s.close();
    10
    s.close();
    11
    s = getSessions().openSession();
    11
    s = getSessions().openSession();
    12
    tx = s.beginTransaction();
    12
    tx = s.beginTransaction();
    13
    s.createQuery("from Document fetch all properties").uniqueResult();
    13
    s.createQuery("from Document fetch all properties").uniqueResult();
    14
    tx.commit();
    14
    tx.commit();
    15
    s.close();
    15
    s.close();
    16
    getSessions().getStatistics().clear();
    16
    getSessions().getStatistics().clear();
    17
    s = getSessions().openSession();
    17
    s = getSessions().openSession();
    18
    tx = s.beginTransaction();
    18
    tx = s.beginTransaction();
    19
    Document d = (Document)s.createCriteria(Document.class).uniqueResult();
    19
    Document d = (Document)s.createCriteria(Document.class).uniqueResult();
    20
    assertFalse(Hibernate.isPropertyInitialized(d, "text"));
    20
    assertFalse(Hibernate.isPropertyInitialized(d, "text"));
    21
    assertFalse(Hibernate.isPropertyInitialized(d, "summary"));
    21
    assertFalse(Hibernate.isPropertyInitialized(d, "summary"));
    22
    assertEquals("Hibernate is....", d.getText());
    22
    assertEquals("Hibernate is....", d.getText());
    23
    assertTrue(Hibernate.isPropertyInitialized(d, "text"));
    23
    assertTrue(Hibernate.isPropertyInitialized(d, "text"));
    24
    assertTrue(Hibernate.isPropertyInitialized(d, "summary"));
    24
    assertTrue(Hibernate.isPropertyInitialized(d, "summary"));
    25
    tx.commit();
    25
    tx.commit();
    26
    s.close();
    26
    s.close();
    27
    assertEquals(1, getSessions().getStatistics().getPrepareStatementCount());
    27
    assertEquals(1, getSessions().getStatistics().getPrepareStatementCount());
    27
    assertEquals(2, getSessions().getStatistics().getPrepareStatementCount());
    Differences
    Expression1Expression2Difference
    12LITERAL_VALUE_MISMATCH
    27
    assertEquals(2, getSessions().getStatistics().getPrepareStatementCount());
    28
    s = getSessions().openSession();
    28
    s = getSessions().openSession();
    29
    tx = s.beginTransaction();
    29
    tx = s.beginTransaction();
    30
    d = (Document)s.get(Document.class, d.getId());
    30
    d = (Document)s.get(Document.class, d.getId());
    31
    assertTrue(Hibernate.isPropertyInitialized(d, "text"));
    31
    assertTrue(Hibernate.isPropertyInitialized(d, "text"));
    31
    assertFalse(Hibernate.isPropertyInitialized(d, "text"));
    Differences
    Expression1Expression2Difference
    assertTrueassertFalseMETHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Expression assertTrue(Hibernate.isPropertyInitialized(d,"text")) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertFalse(Hibernate.isPropertyInitialized(d,"text")) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertTrue(Hibernate.isPropertyInitialized(d,"text")) is a void method call, and thus it cannot be parameterized
    Expression assertFalse(Hibernate.isPropertyInitialized(d,"text")) is a void method call, and thus it cannot be parameterized
    31
    assertFalse(Hibernate.isPropertyInitialized(d, "text"));
    32
    assertTrue(Hibernate.isPropertyInitialized(d, "summary"));
    32
    assertTrue(Hibernate.isPropertyInitialized(d, "summary"));
    32
    assertFalse(Hibernate.isPropertyInitialized(d, "summary"));
    Differences
    Expression1Expression2Difference
    assertTrueassertFalseMETHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Expression assertTrue(Hibernate.isPropertyInitialized(d,"summary")) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertFalse(Hibernate.isPropertyInitialized(d,"summary")) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertTrue(Hibernate.isPropertyInitialized(d,"summary")) is a void method call, and thus it cannot be parameterized
    Expression assertFalse(Hibernate.isPropertyInitialized(d,"summary")) is a void method call, and thus it cannot be parameterized
    32
    assertFalse(Hibernate.isPropertyInitialized(d, "summary"));
    33
    tx.commit();
    33
    tx.commit();
    34
    s.close();
    34
    s.close();
    Precondition Violations (8)
    Row Violation
    1Expression assertTrue(Hibernate.isPropertyInitialized(d,"text")) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression assertFalse(Hibernate.isPropertyInitialized(d,"text")) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression assertTrue(Hibernate.isPropertyInitialized(d,"text")) is a void method call, and thus it cannot be parameterized
    4Expression assertFalse(Hibernate.isPropertyInitialized(d,"text")) is a void method call, and thus it cannot be parameterized
    5Expression assertTrue(Hibernate.isPropertyInitialized(d,"summary")) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Expression assertFalse(Hibernate.isPropertyInitialized(d,"summary")) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7Expression assertTrue(Hibernate.isPropertyInitialized(d,"summary")) is a void method call, and thus it cannot be parameterized
    8Expression assertFalse(Hibernate.isPropertyInitialized(d,"summary")) is a void method call, and thus it cannot be parameterized