Person p = new Person(); p.setIdentity( new Identity() ); Account a = new Account(); a.setNumber("123-12345-1236"); a.setOwner(p); p.getIdentity().setName("Gavin"); p.getIdentity().setSsn("123-12-1234"); Session s = openSession(); Transaction tx = s.beginTransaction(); s.persist(p); s.persist(a); s.flush(); s.clear(); a = (Account) s.createQuery("from Account a left join fetch a.owner").uniqueResult(); assertTrue( Hibernate.isInitialized( a.getOwner() ) ); assertNotNull( a.getOwner() ); assertEquals( "Gavin", a.getOwner().getIdentity().getName() ); s.clear(); a = (Account) s.get(Account.class, "123-12345-1236"); assertFalse( Hibernate.isInitialized( a.getOwner() ) ); assertNotNull( a.getOwner() ); assertEquals( "Gavin", a.getOwner().getIdentity().getName() ); assertTrue( Hibernate.isInitialized( a.getOwner() ) ); s.clear(); getSessions().evict(Account.class); getSessions().evict(Person.class); a = (Account) s.get(Account.class, "123-12345-1236"); assertTrue( Hibernate.isInitialized( a.getOwner() ) ); assertNotNull( a.getOwner() ); assertEquals( "Gavin", a.getOwner().getIdentity().getName() ); assertTrue( Hibernate.isInitialized( a.getOwner() ) ); s.delete( a ); s.delete( a.getOwner() ); tx.commit(); s.close();
Person p = new Person(); p.setIdentity( new Identity() ); Account a = new Account(); a.setNumber("123-12345-1236"); a.setOwner(p); p.getIdentity().setName("Gavin"); p.getIdentity().setSsn("123-12-1234"); Session s = openSession(); Transaction tx = s.beginTransaction(); s.persist(p); s.persist(a); s.flush(); s.clear(); a = (Account) s.createQuery("from Account a left join fetch a.owner").uniqueResult(); assertTrue( Hibernate.isInitialized( a.getOwner() ) ); assertNotNull( a.getOwner() ); assertEquals( "Gavin", a.getOwner().getIdentity().getName() ); s.clear(); a = (Account) s.get(Account.class, "123-12345-1236"); assertFalse( Hibernate.isInitialized( a.getOwner() ) ); assertNotNull( a.getOwner() ); assertEquals( "Gavin", a.getOwner().getIdentity().getName() ); assertTrue( Hibernate.isInitialized( a.getOwner() ) ); s.clear(); getSessions().evict(Account.class); getSessions().evict(Person.class); a = (Account) s.get(Account.class, "123-12345-1236"); assertTrue( Hibernate.isInitialized( a.getOwner() ) ); assertNotNull( a.getOwner() ); assertEquals( "Gavin", a.getOwner().getIdentity().getName() ); assertTrue( Hibernate.isInitialized( a.getOwner() ) ); s.delete( a ); s.delete( a.getOwner() ); 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/propertyref/component/complete/CompleteComponentPropertyRefTest.java File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/propertyref/component/partial/PartialComponentPropertyRefTest.java
Method name: void testComponentPropertyRef() Method name: void testComponentPropertyRef()
Number of AST nodes: 35 Number of AST nodes: 35
1
Person p = new Person();
1
Person p = new Person();
2
		p.setIdentity( new Identity() );
2
		p.setIdentity( new Identity() );
3
		Account a = new Account();
3
		Account a = new Account();
4
		a.setNumber("123-12345-1236");
4
		a.setNumber("123-12345-1236");
5
		a.setOwner(p);
5
		a.setOwner(p);
6
		p.getIdentity().setName("Gavin");
6
		p.getIdentity().setName("Gavin");
7
		p.getIdentity().setSsn("123-12-1234");
7
		p.getIdentity().setSsn("123-12-1234");
8
		Session s = openSession();
8
		Session s = openSession();
9
		Transaction tx = s.beginTransaction();
9
		Transaction tx = s.beginTransaction();
10
		s.persist(p);
10
		s.persist(p);
11
		s.persist(a);
11
		s.persist(a);
12
		s.flush();
12
		s.flush();
13
		s.clear();
13
		s.clear();
14
		
14
		a = (Account) s.createQuery("from Account a left join fetch a.owner").uniqueResult();
15
		a = (Account) s.createQuery("from Account a left join fetch a.owner").uniqueResult();
15
		assertTrue( Hibernate.isInitialized( a.getOwner() ) );
16
		assertTrue( Hibernate.isInitialized( a.getOwner() ) );
16
		assertNotNull( a.getOwner() );
17
		assertNotNull( a.getOwner() );
17
		assertEquals( "Gavin", a.getOwner().getIdentity().getName() );
18
		assertEquals( "Gavin", a.getOwner().getIdentity().getName() );
18
		s.clear();
19
		s.clear();
20
		
19
		a = (Account) s.get(Account.class, "123-12345-1236");
21
		a = (Account) s.get(Account.class, "123-12345-1236");
20
		assertFalse( Hibernate.isInitialized( a.getOwner() ) );
22
		assertFalse( Hibernate.isInitialized( a.getOwner() ) );
21
		assertNotNull( a.getOwner() );
23
		assertNotNull( a.getOwner() );
22
		assertEquals( "Gavin", a.getOwner().getIdentity().getName() );
24
		assertEquals( "Gavin", a.getOwner().getIdentity().getName() );
23
		assertTrue( Hibernate.isInitialized( a.getOwner() ) );
25
		assertTrue( Hibernate.isInitialized( a.getOwner() ) );
26
		
24
		s.clear();
27
		s.clear();
28
		
25
		getSessions().evict(Account.class);
29
		getSessions().evict(Account.class);
26
		getSessions().evict(Person.class);
30
		getSessions().evict(Person.class);
31
		
27
		a = (Account) s.get(Account.class, "123-12345-1236");
32
		a = (Account) s.get(Account.class, "123-12345-1236");
28
		assertTrue( Hibernate.isInitialized( a.getOwner() ) );
33
		assertTrue( Hibernate.isInitialized( a.getOwner() ) );
29
		assertNotNull( a.getOwner() );
34
		assertNotNull( a.getOwner() );
30
		assertEquals( "Gavin", a.getOwner().getIdentity().getName() );
35
		assertEquals( "Gavin", a.getOwner().getIdentity().getName() );
31
		assertTrue( Hibernate.isInitialized( a.getOwner() ) );
36
		assertTrue( Hibernate.isInitialized( a.getOwner() ) );
37
		
32
		s.delete( a );
38
		s.delete( a );
33
		s.delete( a.getOwner() );
39
		s.delete( a.getOwner() );
34
		tx.commit();
40
		tx.commit();
35
		s.close();
41
		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.0
Clones locationClones are in different classes having the same super class
Number of node comparisons249
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements35
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)0.0
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    Person p = new Person();
    1
    Person p = new Person();
    2
    p.setIdentity(new Identity());
    2
    p.setIdentity(new Identity());
    2
    p.setIdentity(new Identity());
    Differences
    Expression1Expression2Difference
    org.hibernate.test.propertyref.component.complete.Identityorg.hibernate.test.propertyref.component.partial.IdentityVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.test.propertyref.component.complete.Identity of variable new Identity() does not match with type org.hibernate.test.propertyref.component.partial.Identity of variable new Identity()
    • Make classes org.hibernate.test.propertyref.component.complete.Identity and org.hibernate.test.propertyref.component.partial.Identity extend a common superclass
    2
    p.setIdentity(new Identity());
    3
    Account a = new Account();
    3
    Account a = new Account();
    4
    a.setNumber("123-12345-1236");
    4
    a.setNumber("123-12345-1236");
    5
    a.setOwner(p);
    5
    a.setOwner(p);
    6
    p.getIdentity().setName("Gavin");
    6
    p.getIdentity().setName("Gavin");
    6
    p.getIdentity().setName("Gavin");
    Differences
    Expression1Expression2Difference
    org.hibernate.test.propertyref.component.complete.Identityorg.hibernate.test.propertyref.component.partial.IdentityVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Expression p.getIdentity() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression p.getIdentity() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Type org.hibernate.test.propertyref.component.complete.Identity of variable p.getIdentity() does not match with type org.hibernate.test.propertyref.component.partial.Identity of variable p.getIdentity()
    • Make classes org.hibernate.test.propertyref.component.complete.Identity and org.hibernate.test.propertyref.component.partial.Identity extend a common superclass
    6
    p.getIdentity().setName("Gavin");
    7
    p.getIdentity().setSsn("123-12-1234");
    7
    p.getIdentity().setSsn("123-12-1234");
    7
    p.getIdentity().setSsn("123-12-1234");
    Differences
    Expression1Expression2Difference
    org.hibernate.test.propertyref.component.complete.Identityorg.hibernate.test.propertyref.component.partial.IdentityVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Expression p.getIdentity() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression p.getIdentity() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Type org.hibernate.test.propertyref.component.complete.Identity of variable p.getIdentity() does not match with type org.hibernate.test.propertyref.component.partial.Identity of variable p.getIdentity()
    • Make classes org.hibernate.test.propertyref.component.complete.Identity and org.hibernate.test.propertyref.component.partial.Identity extend a common superclass
    7
    p.getIdentity().setSsn("123-12-1234");
    8
    Session s = openSession();
    8
    Session s = openSession();
    9
    Transaction tx = s.beginTransaction();
    9
    Transaction tx = s.beginTransaction();
    10
    s.persist(p);
    10
    s.persist(p);
    11
    s.persist(a);
    11
    s.persist(a);
    12
    s.flush();
    12
    s.flush();
    13
    s.clear();
    13
    s.clear();
    14
    a = (Account)s.createQuery("from Account a left join fetch a.owner").uniqueResult();
    14
    a = (Account)s.createQuery("from Account a left join fetch a.owner").uniqueResult();
    15
    assertTrue(Hibernate.isInitialized(a.getOwner()));
    15
    assertTrue(Hibernate.isInitialized(a.getOwner()));
    16
    assertNotNull(a.getOwner());
    16
    assertNotNull(a.getOwner());
    17
    assertEquals("Gavin", a.getOwner().getIdentity().getName());
    17
    assertEquals("Gavin", a.getOwner().getIdentity().getName());
    17
    assertEquals("Gavin", a.getOwner().getIdentity().getName());
    Differences
    Expression1Expression2Difference
    org.hibernate.test.propertyref.component.complete.Identityorg.hibernate.test.propertyref.component.partial.IdentityVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Expression a.getOwner().getIdentity() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression a.getOwner().getIdentity() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Type org.hibernate.test.propertyref.component.complete.Identity of variable a.getOwner().getIdentity() does not match with type org.hibernate.test.propertyref.component.partial.Identity of variable a.getOwner().getIdentity()
    • Make classes org.hibernate.test.propertyref.component.complete.Identity and org.hibernate.test.propertyref.component.partial.Identity extend a common superclass
    17
    assertEquals("Gavin", a.getOwner().getIdentity().getName());
    18
    s.clear();
    18
    s.clear();
    19
    a = (Account)s.get(Account.class, "123-12345-1236");
    19
    a = (Account)s.get(Account.class, "123-12345-1236");
    20
    assertFalse(Hibernate.isInitialized(a.getOwner()));
    20
    assertFalse(Hibernate.isInitialized(a.getOwner()));
    21
    assertNotNull(a.getOwner());
    21
    assertNotNull(a.getOwner());
    22
    assertEquals("Gavin", a.getOwner().getIdentity().getName());
    22
    assertEquals("Gavin", a.getOwner().getIdentity().getName());
    22
    assertEquals("Gavin", a.getOwner().getIdentity().getName());
    Differences
    Expression1Expression2Difference
    org.hibernate.test.propertyref.component.complete.Identityorg.hibernate.test.propertyref.component.partial.IdentityVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Expression a.getOwner().getIdentity() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression a.getOwner().getIdentity() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Type org.hibernate.test.propertyref.component.complete.Identity of variable a.getOwner().getIdentity() does not match with type org.hibernate.test.propertyref.component.partial.Identity of variable a.getOwner().getIdentity()
    • Make classes org.hibernate.test.propertyref.component.complete.Identity and org.hibernate.test.propertyref.component.partial.Identity extend a common superclass
    22
    assertEquals("Gavin", a.getOwner().getIdentity().getName());
    23
    assertTrue(Hibernate.isInitialized(a.getOwner()));
    23
    assertTrue(Hibernate.isInitialized(a.getOwner()));
    24
    s.clear();
    24
    s.clear();
    25
    getSessions().evict(Account.class);
    25
    getSessions().evict(Account.class);
    26
    getSessions().evict(Person.class);
    26
    getSessions().evict(Person.class);
    27
    a = (Account)s.get(Account.class, "123-12345-1236");
    27
    a = (Account)s.get(Account.class, "123-12345-1236");
    28
    assertTrue(Hibernate.isInitialized(a.getOwner()));
    28
    assertTrue(Hibernate.isInitialized(a.getOwner()));
    29
    assertNotNull(a.getOwner());
    29
    assertNotNull(a.getOwner());
    30
    assertEquals("Gavin", a.getOwner().getIdentity().getName());
    30
    assertEquals("Gavin", a.getOwner().getIdentity().getName());
    30
    assertEquals("Gavin", a.getOwner().getIdentity().getName());
    Differences
    Expression1Expression2Difference
    org.hibernate.test.propertyref.component.complete.Identityorg.hibernate.test.propertyref.component.partial.IdentityVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Expression a.getOwner().getIdentity() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression a.getOwner().getIdentity() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Type org.hibernate.test.propertyref.component.complete.Identity of variable a.getOwner().getIdentity() does not match with type org.hibernate.test.propertyref.component.partial.Identity of variable a.getOwner().getIdentity()
    • Make classes org.hibernate.test.propertyref.component.complete.Identity and org.hibernate.test.propertyref.component.partial.Identity extend a common superclass
    30
    assertEquals("Gavin", a.getOwner().getIdentity().getName());
    31
    assertTrue(Hibernate.isInitialized(a.getOwner()));
    31
    assertTrue(Hibernate.isInitialized(a.getOwner()));
    32
    s.delete(a);
    32
    s.delete(a);
    33
    s.delete(a.getOwner());
    33
    s.delete(a.getOwner());
    34
    tx.commit();
    34
    tx.commit();
    35
    s.close();
    35
    s.close();
    Precondition Violations (16)
    Row Violation
    1Type org.hibernate.test.propertyref.component.complete.Identity of variable new Identity() does not match with type org.hibernate.test.propertyref.component.partial.Identity of variable new Identity()
    2Expression p.getIdentity() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression p.getIdentity() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Type org.hibernate.test.propertyref.component.complete.Identity of variable p.getIdentity() does not match with type org.hibernate.test.propertyref.component.partial.Identity of variable p.getIdentity()
    5Expression p.getIdentity() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Expression p.getIdentity() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7Type org.hibernate.test.propertyref.component.complete.Identity of variable p.getIdentity() does not match with type org.hibernate.test.propertyref.component.partial.Identity of variable p.getIdentity()
    8Expression a.getOwner().getIdentity() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    9Expression a.getOwner().getIdentity() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    10Type org.hibernate.test.propertyref.component.complete.Identity of variable a.getOwner().getIdentity() does not match with type org.hibernate.test.propertyref.component.partial.Identity of variable a.getOwner().getIdentity()
    11Expression a.getOwner().getIdentity() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    12Expression a.getOwner().getIdentity() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    13Type org.hibernate.test.propertyref.component.complete.Identity of variable a.getOwner().getIdentity() does not match with type org.hibernate.test.propertyref.component.partial.Identity of variable a.getOwner().getIdentity()
    14Expression a.getOwner().getIdentity() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    15Expression a.getOwner().getIdentity() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    16Type org.hibernate.test.propertyref.component.complete.Identity of variable a.getOwner().getIdentity() does not match with type org.hibernate.test.propertyref.component.partial.Identity of variable a.getOwner().getIdentity()