Session s = openSession(); s.beginTransaction(); Customer cust = new Customer( "Acme, Inc." ); Order order = new Order( new Order.Id( cust, 1 ) ); cust.getOrders().add( order ); s.save( cust ); s.getTransaction().commit(); s.close(); s = openSession(); s.beginTransaction(); try { cust = ( Customer ) s.get( Customer.class, cust.getId() ); } catch( OverflowCondition overflow ) { fail( "get()/load() caused overflow condition" ); } s.delete( cust ); s.getTransaction().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/keymanytoone/bidir/component/EagerKeyManyToOneTest.java File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/typedmanytoone/TypedManyToOneTest.java
Method name: void testLoadEntityWithEagerFetchingToKeyManyToOneReferenceBackToSelfFailureExpected() Method name: void testCreateQueryNull()
Number of AST nodes: 15 Number of AST nodes: 17
1
Session s = openSession();
2
		s.beginTransaction();
3
		Customer cust = new Customer( "Acme, Inc." );
1
Customer cust = new Customer();
4
		Order order = new Order( new Order.Id( cust, 1 ) );
2
		cust.setCustomerId("xyz123");
5
		cust.getOrders().add( order );
3
		cust.setName("Matt");
6
		s.save( cust 
4
		
7
);
5
		Session s = openSession();
8
		s.getTransaction()
6
		Transaction t = s.beginTransaction();
7
		s.persist(cust);
9
.commit();
8
		t.commit();
10
		s.close();
9
		s.close();
11

10
		
12
		s = openSession();
11
		s = openSession();
13
		s.beginTransaction();
12
		t = s.beginTransaction();
14
		try {
13
		
15
			cust = ( Customer ) s.get( Customer.class, cust.getId() );
14
List results = s.createQuery("from Customer cust left join fetch cust.billingAddress where cust.customerId='xyz123'").list();
16
		}
15
		
17
		catch( OverflowCondition overflow ) {
18
			fail( "get()/load()
16
//List results = s.createQuery("from Customer cust left join fetch cust.billingAddress left join fetch cust.shippingAddress").list();
17
		cust = (Customer) results.get(0);
19
 caused overflow condition" );
18
		assertNull( cus
20
		}
19
t.getShippingAddress() );
20
		assertNull( cust.getBillingAddress() );
21
		s.delete( cust );
21
		s.delete( cust );
22
		s.getTransaction().commit();
22
		t.commit();
23
		s.close();
23
		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 comparisons169
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements5
    Number of unmapped statements in the first code fragment8
    Number of unmapped statements in the second code fragment12
    Time elapsed for statement mapping (ms)0.0
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
                                                                    
    1
    Customer cust = new Customer();
                                                                    
    2
    cust.setCustomerId("xyz123");
    Preondition Violations
    Unmatched statement cust.setCustomerId("xyz123"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    2
    cust.setCustomerId("xyz123");
    1
    Session s = openSession();
    4
    Session s = openSession();
    2
    s.beginTransaction();
    2
    s.beginTransaction();
    Preondition Violations
    Unmatched statement s.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                    
                                                    
    3
    cust.setName("Matt");
    Preondition Violations
    Unmatched statement cust.setName("Matt"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    3
    cust.setName("Matt");
    3
    Customer cust = new Customer("Acme, Inc.");
    3
    Customer cust = new Customer("Acme, Inc.");
    Preondition Violations
    Unmatched statement Customer cust=new Customer("Acme, Inc."); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                                            
    4
    Order order = new Order(new Order.Id(cust, 1));
    4
    Order order = new Order(new Order.Id(cust, 1));
    Preondition Violations
    Unmatched statement Order order=new Order(new Order.Id(cust,1)); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                                                  
                                                                                
    5
    Transaction t = s.beginTransaction();
    Preondition Violations
    Unmatched statement Transaction t=s.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5
    Transaction t = s.beginTransaction();
    5
    cust.getOrders().add(order);
                                                                  
                                          
    6
    s.persist(cust);
    Preondition Violations
    Unmatched statement s.persist(cust); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    6
    s.persist(cust);
    6
    s.save(cust);
    6
    s.save(cust);
    Preondition Violations
    Unmatched statement s.save(cust); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                    
                                
    7
    t.commit();
    Preondition Violations
    Unmatched statement t.commit(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    7
    t.commit();
    7
    s.getTransaction().commit();
    7
    s.getTransaction().commit();
    Preondition Violations
    Unmatched statement s.getTransaction().commit(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                  
    8
    s.close();
    8
    s.close();
    9
    s = openSession();
    9
    s = openSession();
                                                          
    10
    t = s.beginTransaction();
    Preondition Violations
    Unmatched statement t=s.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    10
    t = s.beginTransaction();
    10
    s.beginTransaction();
    10
    s.beginTransaction();
    Preondition Violations
    Unmatched statement s.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                      
                                                                                                                                                                                                                                                                  
    11
    List results = s.createQuery("from Customer cust left join fetch cust.billingAddress where cust.customerId='xyz123'").list();
    Preondition Violations
    Unmatched statement List results=s.createQuery("from Customer cust left join fetch cust.billingAddress where cust.customerId='xyz123'").list(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    11
    List results = s.createQuery("from Customer cust left join fetch cust.billingAddress where cust.customerId='xyz123'").list();
                                                                        
    12
    cust = (Customer)results.get(0);
                                                                                        
    13
    assertNull(cust.getShippingAddress());
                                                                                      
    14
    assertNull(cust.getBillingAddress());
    13
    s.delete(cust);
    13
    s.delete(cust);
    15
    s.delete(cust);
    Differences
    Expression1Expression2Difference
    org.hibernate.test.keymanytoone.bidir.component.Customerorg.hibernate.test.typedmanytoone.CustomerVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.test.keymanytoone.bidir.component.Customer of variable cust does not match with type org.hibernate.test.typedmanytoone.Customer of variable cust
    • Make classes org.hibernate.test.keymanytoone.bidir.component.Customer and org.hibernate.test.typedmanytoone.Customer extend a common superclass
    15
    s.delete(cust);
    14
    s.getTransaction().commit();
    14
    s.getTransaction().commit();
    Preondition Violations
    Unmatched statement s.getTransaction().commit(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                    
                                  
    16
    t.commit();
    Preondition Violations
    Unmatched statement t.commit(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    16
    t.commit();
    15
    s.close();
    17
    s.close();
    Precondition Violations (16)
    Row Violation
    1Unmatched statement cust.setCustomerId("xyz123"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    2Unmatched statement s.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Unmatched statement cust.setName("Matt"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    4Unmatched statement Customer cust=new Customer("Acme, Inc."); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    5Unmatched statement Order order=new Order(new Order.Id(cust,1)); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    6Unmatched statement Transaction t=s.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    7Unmatched statement s.persist(cust); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    8Unmatched statement s.save(cust); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    9Unmatched statement t.commit(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    10Unmatched statement s.getTransaction().commit(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    11Unmatched statement t=s.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    12Unmatched statement s.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    13Unmatched statement List results=s.createQuery("from Customer cust left join fetch cust.billingAddress where cust.customerId='xyz123'").list(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    14Type org.hibernate.test.keymanytoone.bidir.component.Customer of variable cust does not match with type org.hibernate.test.typedmanytoone.Customer of variable cust
    15Unmatched statement s.getTransaction().commit(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    16Unmatched statement t.commit(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted