Session s = openSession(); s.beginTransaction(); A a = new A(); a.setData( "Anna" ); s.save( a ); s.getTransaction().commit(); s.close(); // modify detached entity modifyEntity( a ); s = openSession(); s.beginTransaction(); a = ( A ) s.merge( a ); s.getTransaction().commit(); s.close(); verifyModifications( a.getId() );
clearCounts(); Session s = openSession(); s.beginTransaction(); Employer emp = new Employer(); s.persist( emp ); s.getTransaction().commit(); s.close(); s = openSession(); s.beginTransaction(); s.delete( emp ); emp = ( Employer ) s.get( Employee.class, emp.getId() ); s.getTransaction().commit(); s.close(); assertNull( "get did not return null after delete", emp );
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/cascade/MultiPathCascadeTest.java File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/ops/GetLoadTest.java
Method name: void testMultiPathMergeModifiedDetached() Method name: void testGetAfterDelete()
Number of AST nodes: 14 Number of AST nodes: 14
1
clearCounts();
1
Session s = openSession();
2
		Session s = openSession();
2
		s.beginTransaction();
3
		s.beginTransaction();
3
		A a = new A();
4
		
4
		a.setData( "Anna" );
5
		s.save( a
5
Employer emp = new Employer();
6
 );
6
		s.persist( emp );
7
		s.getTransaction().commit();
7
		s.getTransaction().commit();
8
		s.close();
8
		s.close();
9
		// modify detached entity
9
		
10
		modifyEntity( a );
11
		s = openSession();
12
		s.beginTransaction();
13
		a = ( A ) s.merge( a );
14
		s.getTransaction().commit();
15
		s.close();
16
		verifyModifications( a.getId()
10
s = openSession();
11
		s.beginTransaction();
12
		s.delete( emp );
13
		emp = ( Employer ) s.get( Employee.class, emp.getId() );
14
		s.getTransaction().commit();
15
		s.close();
17
 );
16
		assertNull( "get did not return null after delete", emp );
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 comparisons76
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements10
    Number of unmapped statements in the first code fragment4
    Number of unmapped statements in the second code fragment4
    Time elapsed for statement mapping (ms)0.0
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    Session s = openSession();
    2
    Session s = openSession();
    2
    s.beginTransaction();
    3
    s.beginTransaction();
    3
    A a = new A();
    3
    A a = new A();
    Preondition Violations
    Unmatched statement A a=new A(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                  
                                                                  
    4
    Employer emp = new Employer();
    4
    a.setData("Anna");
    4
    a.setData("Anna");
    Preondition Violations
    Unmatched statement a.setData("Anna"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                              
                                        
    5
    s.persist(emp);
    Preondition Violations
    Unmatched statement s.persist(emp); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5
    s.persist(emp);
    5
    s.save(a);
    5
    s.save(a);
    Preondition Violations
    Unmatched statement s.save(a); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                              
    6
    s.getTransaction().commit();
    6
    s.getTransaction().commit();
    7
    s.close();
    7
    s.close();
    8
    modifyEntity(a);
    8
    modifyEntity(a);
    1
    clearCounts();
    Differences
    Expression1Expression2Difference
    modifyEntityclearCountsMETHOD_INVOCATION_NAME_MISMATCH
    modifyEntity(a)clearCounts()ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression modifyEntity(a) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    • Inline private method modifyEntity
    Expression modifyEntity(a) is a void method call, and thus it cannot be parameterized
    Expression clearCounts() is a void method call, and thus it cannot be parameterized
    Expression modifyEntity(a) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    • Inline private method modifyEntity
    Expression modifyEntity(a) is a void method call, and thus it cannot be parameterized
    Expression clearCounts() is a void method call, and thus it cannot be parameterized
    1
    clearCounts();
    9
    s = openSession();
    8
    s = openSession();
    10
    s.beginTransaction();
    9
    s.beginTransaction();
                                        
    10
    s.delete(emp);
    Preondition Violations
    Unmatched statement s.delete(emp); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    10
    s.delete(emp);
                                                                                                            
    11
    emp = (Employer)s.get(Employee.class, emp.getId());
    Preondition Violations
    Unmatched statement emp=(Employer)s.get(Employee.class,emp.getId()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    11
    emp = (Employer)s.get(Employee.class, emp.getId());
    11
    a = (A)s.merge(a);
    11
    a = (A)s.merge(a);
    Preondition Violations
    Unmatched statement a=(A)s.merge(a); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                            
    12
    s.getTransaction().commit();
    12
    s.getTransaction().commit();
    13
    s.close();
    13
    s.close();
    14
    verifyModifications(a.getId());
    14
    verifyModifications(a.getId());
    14
    assertNull("get did not return null after delete", emp);
    Differences
    Expression1Expression2Difference
    verifyModificationsassertNullMETHOD_INVOCATION_NAME_MISMATCH
    verifyModifications(a.getId())assertNull("get did not return null after delete",emp)TYPE_COMPATIBLE_REPLACEMENT
    verifyModifications(a.getId())assertNull("get did not return null after delete",emp)ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression verifyModifications(a.getId()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    • Inline private method verifyModifications
    Expression assertNull("get did not return null after delete",emp) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression verifyModifications(a.getId()) is a void method call, and thus it cannot be parameterized
    Expression assertNull("get did not return null after delete",emp) is a void method call, and thus it cannot be parameterized
    Expression verifyModifications(a.getId()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    • Inline private method verifyModifications
    Expression assertNull("get did not return null after delete",emp) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression verifyModifications(a.getId()) is a void method call, and thus it cannot be parameterized
    Expression assertNull("get did not return null after delete",emp) is a void method call, and thus it cannot be parameterized
    14
    assertNull("get did not return null after delete", emp);
    Precondition Violations (21)
    Row Violation
    1Unmatched statement A a=new A(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    2Unmatched statement a.setData("Anna"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    3Unmatched statement s.persist(emp); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4Unmatched statement s.save(a); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5Expression modifyEntity(a) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Expression modifyEntity(a) is a void method call, and thus it cannot be parameterized
    7Expression clearCounts() is a void method call, and thus it cannot be parameterized
    8Expression modifyEntity(a) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    9Expression modifyEntity(a) is a void method call, and thus it cannot be parameterized
    10Expression clearCounts() is a void method call, and thus it cannot be parameterized
    11Unmatched statement s.delete(emp); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    12Unmatched statement emp=(Employer)s.get(Employee.class,emp.getId()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    13Unmatched statement a=(A)s.merge(a); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    14Expression verifyModifications(a.getId()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    15Expression assertNull("get did not return null after delete",emp) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    16Expression verifyModifications(a.getId()) is a void method call, and thus it cannot be parameterized
    17Expression assertNull("get did not return null after delete",emp) is a void method call, and thus it cannot be parameterized
    18Expression verifyModifications(a.getId()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    19Expression assertNull("get did not return null after delete",emp) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    20Expression verifyModifications(a.getId()) is a void method call, and thus it cannot be parameterized
    21Expression assertNull("get did not return null after delete",emp) is a void method call, and thus it cannot be parameterized