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();
Session s = openSession(); Vetoer v = new Vetoer(); v.setStrings( new String[] { "foo", "bar", "baz" } ); s.save(v); Serializable id = s.save(v); v.getStrings()[1] = "osama"; s.flush(); s.connection().commit(); s.close(); s = openSession(); v = (Vetoer) s.load(Vetoer.class, id); assertTrue( "serializable type", v.getStrings()[1].equals("osama") ); s.delete(v); s.delete(v); s.flush(); s.connection().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/legacy/FooBarTest.java
Method name: void testLoadEntityWithEagerFetchingToKeyManyToOneReferenceBackToSelfFailureExpected() Method name: void testSerializableType()
Number of AST nodes: 15 Number of AST nodes: 17
1
Session s = openSession();
1
Session s = openSession();
2
		s.beginTransaction();
2
		Vetoer v = new Vetoer();
3
		Customer cust = new Customer( "Acme, Inc." );
3
		v.setStrings( new String[] { "foo", "bar", "baz" } );
4
		Order order = new Order( new Order.Id( cust, 1 ) );
4
		s.save(v); Serializable id = s.save(v);
5
		cust.getOrders().add( order );
5
		
6
		s.save( cust 
6
v.getStrings()[1] = "osama";
7
);
7
		s.flush();
8
		s.getTransaction().commit();
8
		s.connection().commit();
9
		s.close();
9
		s.close();
10

11
		s = openSession();
10
		s = openSession();
12
		s.beginTransaction();
11
		
13
		try {
14
			cust = ( Customer ) s.get( Customer.class, cust.getId() );
12
v = (Vetoer) s.load(Vetoer.class, id);
15
		}
13
		
16
		catch( OverflowCondition overflow ) {
17
			fail( "get()/load() caused overflow condition" );
18
		}
19
		s.delete( cust 
14
assertTrue( "serializable type", v.getStrings()[1].equals("osama") );
15
		s.delete(v); s.delete(v);
20
);
16
		s.flush();
21
		s.getTransaction().commit();
17
		s.connection().commit();
22
		s.close();
18
		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 statements6
    Number of unmapped statements in the first code fragment9
    Number of unmapped statements in the second code fragment11
    Time elapsed for statement mapping (ms)0.0
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
                                                          
    1
    Session s = openSession();
    1
    Session s = openSession();
                                                          
                                                      
    2
    Vetoer v = new Vetoer();
    2
    s.beginTransaction();
                                                    
                                                                                                      
    3
    v.setStrings(new String[] {"foo", "bar", "baz"});
    3
    Customer cust = new Customer("Acme, Inc.");
                                                                                            
    4
    Order order = new Order(new Order.Id(cust, 1));
                                                                                                  
    5
    cust.getOrders().add(order);
                                                                  
    6
    s.save(cust);
    6
    s.save(cust);
    4
    s.save(v);
    Differences
    Expression1Expression2Difference
    custvVARIABLE_NAME_MISMATCH
    org.hibernate.test.keymanytoone.bidir.component.Customerorg.hibernate.test.legacy.VetoerVARIABLE_TYPE_MISMATCH
    org.hibernate.Sessionorg.hibernate.classic.SessionVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.test.keymanytoone.bidir.component.Customer of variable cust does not match with type org.hibernate.test.legacy.Vetoer of variable v
    • Make classes org.hibernate.test.keymanytoone.bidir.component.Customer and org.hibernate.test.legacy.Vetoer extend a common superclass
    Type org.hibernate.Session of variable s does not match with type org.hibernate.classic.Session of variable s
    • Make classes org.hibernate.Session and org.hibernate.classic.Session extend a common superclass
    4
    s.save(v);
                                                              
    5
    Serializable id = s.save(v);
                                                              
    6
    v.getStrings()[1] = "osama";
                              
    7
    s.flush();
    7
    s.getTransaction().commit();
    7
    s.getTransaction().commit();
    8
    s.connection().commit();
    Differences
    Expression1Expression2Difference
    getTransactionconnectionMETHOD_INVOCATION_NAME_MISMATCH
    org.hibernate.Transactionjava.sql.ConnectionVARIABLE_TYPE_MISMATCH
    org.hibernate.Sessionorg.hibernate.classic.SessionVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.Transaction of variable s.getTransaction() does not match with type java.sql.Connection of variable s.connection()
    • Make classes org.hibernate.Transaction and java.sql.Connection extend a common superclass
    Type org.hibernate.Session of variable s does not match with type org.hibernate.classic.Session of variable s
    • Make classes org.hibernate.Session and org.hibernate.classic.Session extend a common superclass
    8
    s.connection().commit();
    8
    s.close();
    8
    s.close();
    9
    s.close();
    Differences
    Expression1Expression2Difference
    org.hibernate.Sessionorg.hibernate.classic.SessionVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.Session of variable s does not match with type org.hibernate.classic.Session of variable s
    • Make classes org.hibernate.Session and org.hibernate.classic.Session extend a common superclass
    9
    s.close();
    9
    s = openSession();
    9
    s = openSession();
    Preondition Violations
    Unmatched statement s=openSession(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                          
                                            
    10
    s = openSession();
    Preondition Violations
    Unmatched statement s=openSession(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    10
    s = openSession();
    10
    s.beginTransaction();
                                                      
                                                                                
    11
    v = (Vetoer)s.load(Vetoer.class, id);
    Preondition Violations
    Unmatched statement v=(Vetoer)s.load(Vetoer.class,id); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    11
    v = (Vetoer)s.load(Vetoer.class, id);
    11
    try
                  
    12
    cust = (Customer)s.get(Customer.class, cust.getId());
    12
    cust = (Customer)s.get(Customer.class, cust.getId());
    Preondition Violations
    Unmatched statement cust=(Customer)s.get(Customer.class,cust.getId()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                                
                                                                                                                                                
    12
    assertTrue("serializable type", v.getStrings()[1].equals("osama"));
    13
    s.delete(cust);
    13
    s.delete(cust);
    13
    s.delete(v);
    Differences
    Expression1Expression2Difference
    custvVARIABLE_NAME_MISMATCH
    org.hibernate.test.keymanytoone.bidir.component.Customerorg.hibernate.test.legacy.VetoerVARIABLE_TYPE_MISMATCH
    org.hibernate.Sessionorg.hibernate.classic.SessionVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.test.keymanytoone.bidir.component.Customer of variable cust does not match with type org.hibernate.test.legacy.Vetoer of variable v
    • Make classes org.hibernate.test.keymanytoone.bidir.component.Customer and org.hibernate.test.legacy.Vetoer extend a common superclass
    Type org.hibernate.Session of variable s does not match with type org.hibernate.classic.Session of variable s
    • Make classes org.hibernate.Session and org.hibernate.classic.Session extend a common superclass
    13
    s.delete(v);
                                    
    14
    s.delete(v);
                                
    15
    s.flush();
    14
    s.getTransaction().commit();
    14
    s.getTransaction().commit();
    16
    s.connection().commit();
    Differences
    Expression1Expression2Difference
    getTransactionconnectionMETHOD_INVOCATION_NAME_MISMATCH
    org.hibernate.Transactionjava.sql.ConnectionVARIABLE_TYPE_MISMATCH
    org.hibernate.Sessionorg.hibernate.classic.SessionVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.Transaction of variable s.getTransaction() does not match with type java.sql.Connection of variable s.connection()
    • Make classes org.hibernate.Transaction and java.sql.Connection extend a common superclass
    Type org.hibernate.Session of variable s does not match with type org.hibernate.classic.Session of variable s
    • Make classes org.hibernate.Session and org.hibernate.classic.Session extend a common superclass
    16
    s.connection().commit();
    15
    s.close();
    15
    s.close();
    17
    s.close();
    Differences
    Expression1Expression2Difference
    org.hibernate.Sessionorg.hibernate.classic.SessionVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.Session of variable s does not match with type org.hibernate.classic.Session of variable s
    • Make classes org.hibernate.Session and org.hibernate.classic.Session extend a common superclass
    17
    s.close();
    Precondition Violations (14)
    Row Violation
    1Type org.hibernate.test.keymanytoone.bidir.component.Customer of variable cust does not match with type org.hibernate.test.legacy.Vetoer of variable v
    2Type org.hibernate.Session of variable s does not match with type org.hibernate.classic.Session of variable s
    3Type org.hibernate.Transaction of variable s.getTransaction() does not match with type java.sql.Connection of variable s.connection()
    4Type org.hibernate.Session of variable s does not match with type org.hibernate.classic.Session of variable s
    5Type org.hibernate.Session of variable s does not match with type org.hibernate.classic.Session of variable s
    6Unmatched statement s=openSession(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    7Unmatched statement s=openSession(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    8Unmatched statement v=(Vetoer)s.load(Vetoer.class,id); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    9Unmatched statement cust=(Customer)s.get(Customer.class,cust.getId()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    10Type org.hibernate.test.keymanytoone.bidir.component.Customer of variable cust does not match with type org.hibernate.test.legacy.Vetoer of variable v
    11Type org.hibernate.Session of variable s does not match with type org.hibernate.classic.Session of variable s
    12Type org.hibernate.Transaction of variable s.getTransaction() does not match with type java.sql.Connection of variable s.connection()
    13Type org.hibernate.Session of variable s does not match with type org.hibernate.classic.Session of variable s
    14Type org.hibernate.Session of variable s does not match with type org.hibernate.classic.Session of variable s