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();
                                  
    4
    a.setData("Anna");
    4
    a.setData("Anna");
    1
    clearCounts();
    Differences
    Expression1Expression2Difference
    setDataclearCountsMETHOD_INVOCATION_NAME_MISMATCH
    a.setData("Anna")clearCounts()ARGUMENT_NUMBER_MISMATCH
    aMISSING_METHOD_INVOCATION_EXPRESSION
    Preondition Violations
    Expression a.setData("Anna") 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 a.setData("Anna") 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();
                                                                  
    4
    Employer emp = new Employer();
                                        
    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);
    14
    assertNull("get did not return null after delete", emp);
    Differences
    Expression1Expression2Difference
    modifyEntityassertNullMETHOD_INVOCATION_NAME_MISMATCH
    modifyEntity(a)assertNull("get did not return null after delete",emp)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 assertNull("get did not return null after delete",emp) 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 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);
    9
    s = openSession();
    8
    s = openSession();
    10
    s.beginTransaction();
    9
    s.beginTransaction();
                                        
    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());
                                                                          
    Precondition Violations (14)
    Row Violation
    1Expression a.setData("Anna") is a void method call, and thus it cannot be parameterized
    2Expression clearCounts() is a void method call, and thus it cannot be parameterized
    3Expression a.setData("Anna") is a void method call, and thus it cannot be parameterized
    4Expression clearCounts() is a void method call, and thus it cannot be parameterized
    5Unmatched statement s.persist(emp); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    6Unmatched statement s.save(a); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    7Expression modifyEntity(a) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8Expression modifyEntity(a) is a void method call, and thus it cannot be parameterized
    9Expression assertNull("get did not return null after delete",emp) is a void method call, and thus it cannot be parameterized
    10Expression modifyEntity(a) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    11Expression modifyEntity(a) is a void method call, and thus it cannot be parameterized
    12Expression assertNull("get did not return null after delete",emp) is a void method call, and thus it cannot be parameterized
    13Unmatched 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
    14Unmatched 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