Customer cust = new Customer(); cust.setCustomerId("xyz123"); cust.setName("Matt"); Session s = openSession(); Transaction t = s.beginTransaction(); s.persist(cust); t.commit(); s.close(); s = openSession(); t = s.beginTransaction(); List results = s.createQuery("from Customer cust left join fetch cust.billingAddress where cust.customerId='xyz123'").list(); //List results = s.createQuery("from Customer cust left join fetch cust.billingAddress left join fetch cust.shippingAddress").list(); cust = (Customer) results.get(0); assertNull( cust.getShippingAddress() ); assertNull( cust.getBillingAddress() ); s.delete( cust ); t.commit(); s.close();
Customer cust = new Customer(); cust.setCustomerId("xyz123"); cust.setName("Matt"); Session s = openSession(); Transaction t = s.beginTransaction(); s.persist(cust); t.commit(); s.close(); s = openSession(); t = s.beginTransaction(); List results = s.createQuery("from Customer cust left join fetch cust.billingAddress where cust.customerId='xyz123'").list(); //List results = s.createQuery("from Customer cust left join fetch cust.billingAddress left join fetch cust.shippingAddress").list(); cust = (Customer) results.get(0); assertNull( cust.getShippingAddress() ); assertNull( cust.getBillingAddress() ); s.delete(cust); 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/typedmanytoone/TypedManyToOneTest.java File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/typedonetoone/TypedOneToOneTest.java
Method name: void testCreateQueryNull() Method name: void testCreateQueryNull()
Number of AST nodes: 17 Number of AST nodes: 17
1
Customer cust = new Customer();
1
Customer cust = new Customer();
2
		cust.setCustomerId("xyz123");
2
		cust.setCustomerId("xyz123");
3
		cust.setName("Matt");
3
		cust.setName("Matt");
4
		
4
		
5
		Session s = openSession();
5
		Session s = openSession();
6
		Transaction t = s.beginTransaction();
6
		Transaction t = s.beginTransaction();
7
		s.persist(cust);
7
		s.persist(cust);
8
		t.commit();
8
		t.commit();
9
		s.close();
9
		s.close();
10
		
10
		
11
		s = openSession();
11
		s = openSession();
12
		t = s.beginTransaction();
12
		t = s.beginTransaction();
13
		List results = s.createQuery("from Customer cust left join fetch cust.billingAddress where cust.customerId='xyz123'").list();
13
		List results = s.createQuery("from Customer cust left join fetch cust.billingAddress where cust.customerId='xyz123'").list();
14
		//List results = s.createQuery("from Customer cust left join fetch cust.billingAddress left join fetch cust.shippingAddress").list();
14
		//List results = s.createQuery("from Customer cust left join fetch cust.billingAddress left join fetch cust.shippingAddress").list();
15
		cust = (Customer) results.get(0);
15
		cust = (Customer) results.get(0);
16
		assertNull( cust.getShippingAddress() );
16
		assertNull( cust.getShippingAddress() );
17
		assertNull( cust.getBillingAddress() );
17
		assertNull( cust.getBillingAddress() );
18
		s.delete( cust );
18
		s.delete(cust);
19
		t.commit();
19
		t.commit();
20
		s.close();
20
		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 comparisons130
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements15
    Number of unmapped statements in the first code fragment2
    Number of unmapped statements in the second code fragment2
    Time elapsed for statement mapping (ms)0.0
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
                                                                    
    1
    Customer cust = new Customer();
    1
    Customer cust = new Customer();
                                                                    
    2
    cust.setCustomerId("xyz123");
    2
    cust.setCustomerId("xyz123");
    2
    cust.setCustomerId("xyz123");
    Differences
    Expression1Expression2Difference
    org.hibernate.test.typedmanytoone.Customerorg.hibernate.test.typedonetoone.CustomerVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.test.typedmanytoone.Customer of variable cust does not match with type org.hibernate.test.typedonetoone.Customer of variable cust
    • Make classes org.hibernate.test.typedmanytoone.Customer and org.hibernate.test.typedonetoone.Customer extend a common superclass
    2
    cust.setCustomerId("xyz123");
    3
    cust.setName("Matt");
    3
    cust.setName("Matt");
    3
    cust.setName("Matt");
    Differences
    Expression1Expression2Difference
    org.hibernate.test.typedmanytoone.Customerorg.hibernate.test.typedonetoone.CustomerVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.test.typedmanytoone.Customer of variable cust does not match with type org.hibernate.test.typedonetoone.Customer of variable cust
    • Make classes org.hibernate.test.typedmanytoone.Customer and org.hibernate.test.typedonetoone.Customer extend a common superclass
    3
    cust.setName("Matt");
    4
    Session s = openSession();
    4
    Session s = openSession();
    5
    Transaction t = s.beginTransaction();
    5
    Transaction t = s.beginTransaction();
    6
    s.persist(cust);
    6
    s.persist(cust);
    6
    s.persist(cust);
    Differences
    Expression1Expression2Difference
    org.hibernate.test.typedmanytoone.Customerorg.hibernate.test.typedonetoone.CustomerVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.test.typedmanytoone.Customer of variable cust does not match with type org.hibernate.test.typedonetoone.Customer of variable cust
    • Make classes org.hibernate.test.typedmanytoone.Customer and org.hibernate.test.typedonetoone.Customer extend a common superclass
    6
    s.persist(cust);
    7
    t.commit();
    7
    t.commit();
    8
    s.close();
    8
    s.close();
    9
    s = openSession();
    9
    s = openSession();
    10
    t = s.beginTransaction();
    10
    t = s.beginTransaction();
    11
    List results = s.createQuery("from Customer cust left join fetch cust.billingAddress where cust.customerId='xyz123'").list();
    11
    List results = s.createQuery("from Customer cust left join fetch cust.billingAddress where cust.customerId='xyz123'").list();
                                                                        
    12
    cust = (Customer)results.get(0);
    Preondition Violations
    Unmatched statement cust=(Customer)results.get(0); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    12
    cust = (Customer)results.get(0);
    12
    cust = (Customer)results.get(0);
    12
    cust = (Customer)results.get(0);
    Preondition Violations
    Unmatched statement cust=(Customer)results.get(0); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                        
    13
    assertNull(cust.getShippingAddress());
    13
    assertNull(cust.getShippingAddress());
    13
    assertNull(cust.getShippingAddress());
    Differences
    Expression1Expression2Difference
    org.hibernate.test.typedmanytoone.Addressorg.hibernate.test.typedonetoone.AddressVARIABLE_TYPE_MISMATCH
    org.hibernate.test.typedmanytoone.Customerorg.hibernate.test.typedonetoone.CustomerVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.test.typedmanytoone.Address of variable cust.getShippingAddress() does not match with type org.hibernate.test.typedonetoone.Address of variable cust.getShippingAddress()
    • Make classes org.hibernate.test.typedmanytoone.Address and org.hibernate.test.typedonetoone.Address extend a common superclass
    Type org.hibernate.test.typedmanytoone.Customer of variable cust does not match with type org.hibernate.test.typedonetoone.Customer of variable cust
    • Make classes org.hibernate.test.typedmanytoone.Customer and org.hibernate.test.typedonetoone.Customer extend a common superclass
    13
    assertNull(cust.getShippingAddress());
    14
    assertNull(cust.getBillingAddress());
    14
    assertNull(cust.getBillingAddress());
    14
    assertNull(cust.getBillingAddress());
    Differences
    Expression1Expression2Difference
    org.hibernate.test.typedmanytoone.Addressorg.hibernate.test.typedonetoone.AddressVARIABLE_TYPE_MISMATCH
    org.hibernate.test.typedmanytoone.Customerorg.hibernate.test.typedonetoone.CustomerVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.test.typedmanytoone.Address of variable cust.getBillingAddress() does not match with type org.hibernate.test.typedonetoone.Address of variable cust.getBillingAddress()
    • Make classes org.hibernate.test.typedmanytoone.Address and org.hibernate.test.typedonetoone.Address extend a common superclass
    Type org.hibernate.test.typedmanytoone.Customer of variable cust does not match with type org.hibernate.test.typedonetoone.Customer of variable cust
    • Make classes org.hibernate.test.typedmanytoone.Customer and org.hibernate.test.typedonetoone.Customer extend a common superclass
    14
    assertNull(cust.getBillingAddress());
    15
    s.delete(cust);
    15
    s.delete(cust);
    15
    s.delete(cust);
    Differences
    Expression1Expression2Difference
    org.hibernate.test.typedmanytoone.Customerorg.hibernate.test.typedonetoone.CustomerVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.test.typedmanytoone.Customer of variable cust does not match with type org.hibernate.test.typedonetoone.Customer of variable cust
    • Make classes org.hibernate.test.typedmanytoone.Customer and org.hibernate.test.typedonetoone.Customer extend a common superclass
    15
    s.delete(cust);
    16
    t.commit();
    16
    t.commit();
    17
    s.close();
    17
    s.close();
    Precondition Violations (10)
    Row Violation
    1Type org.hibernate.test.typedmanytoone.Customer of variable cust does not match with type org.hibernate.test.typedonetoone.Customer of variable cust
    2Type org.hibernate.test.typedmanytoone.Customer of variable cust does not match with type org.hibernate.test.typedonetoone.Customer of variable cust
    3Type org.hibernate.test.typedmanytoone.Customer of variable cust does not match with type org.hibernate.test.typedonetoone.Customer of variable cust
    4Unmatched statement cust=(Customer)results.get(0); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5Unmatched statement cust=(Customer)results.get(0); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    6Type org.hibernate.test.typedmanytoone.Address of variable cust.getShippingAddress() does not match with type org.hibernate.test.typedonetoone.Address of variable cust.getShippingAddress()
    7Type org.hibernate.test.typedmanytoone.Customer of variable cust does not match with type org.hibernate.test.typedonetoone.Customer of variable cust
    8Type org.hibernate.test.typedmanytoone.Address of variable cust.getBillingAddress() does not match with type org.hibernate.test.typedonetoone.Address of variable cust.getBillingAddress()
    9Type org.hibernate.test.typedmanytoone.Customer of variable cust does not match with type org.hibernate.test.typedonetoone.Customer of variable cust
    10Type org.hibernate.test.typedmanytoone.Customer of variable cust does not match with type org.hibernate.test.typedonetoone.Customer of variable cust