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() );
Session s = openSession(); s.beginTransaction(); Item item = new Item(); item.setName( "dummy" ); s.persist( item ); s.getTransaction().commit(); s.close(); s = openSession(); s.beginTransaction(); s.delete( item ); boolean contains = s.contains( item ); s.getTransaction().commit(); s.close(); assertFalse( "expecting removed entity to not be contained", contains );
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/jpa/removed/RemovedEntityTest.java
Method name: void testMultiPathMergeModifiedDetached() Method name: void testRemoveThenContains()
Number of AST nodes: 14 Number of AST nodes: 14
1
Session s = openSession();
1
Session s = openSession();
2
		s.beginTransaction();
2
		s.beginTransaction();
3
		A a = new A();
3
		Item item = new Item();
4
		a.setData( "Anna" );
4
		item.setName( "dummy" );
5
		s.save( a );
5
		s.persist( item );
6
		s.getTransaction().commit();
6
		s.getTransaction().commit();
7
		s.close();
7
		s.close();
8
		// modify detached entity
9
		modifyEntity( a );
8

10
		s = openSession();
9
		s = openSession();
11
		s.beginTransaction();
10
		s.beginTransaction();
12
		a = ( A ) s.merge( a
11
		s.delete( item );
13
 );
12
		boolean contains = s.contains( item );
14
		s.getTransaction().commit();
13
		s.getTransaction().commit();
15
		s.close();
14
		s.close();
16
		verifyModifications( a.getId()
17
 );
15
		assertFalse( "expecting removed entity to not be contained", contains );
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 statements9
    Number of unmapped statements in the first code fragment5
    Number of unmapped statements in the second code fragment5
    Time elapsed for statement mapping (ms)0.0
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    Session s = openSession();
    1
    Session s = openSession();
    2
    s.beginTransaction();
    2
    s.beginTransaction();
                                                    
    3
    Item item = new Item();
    3
    A a = new A();
                                  
                                                      
    4
    item.setName("dummy");
                                          
    5
    s.persist(item);
    Preondition Violations
    Unmatched statement s.persist(item); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5
    s.persist(item);
    4
    a.setData("Anna");
    4
    a.setData("Anna");
    14
    assertFalse("expecting removed entity to not be contained", contains);
    Differences
    Expression1Expression2Difference
    setDataassertFalseMETHOD_INVOCATION_NAME_MISMATCH
    a.setData("Anna")assertFalse("expecting removed entity to not be contained",contains)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 assertFalse("expecting removed entity to not be contained",contains) 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 assertFalse("expecting removed entity to not be contained",contains) is a void method call, and thus it cannot be parameterized
    14
    assertFalse("expecting removed entity to not be contained", contains);
    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);
    Preondition Violations
    Unmatched statement modifyEntity(a); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                          
    9
    s = openSession();
    8
    s = openSession();
    10
    s.beginTransaction();
    9
    s.beginTransaction();
                                          
    10
    s.delete(item);
                                                                                
    11
    boolean contains = s.contains(item);
    Preondition Violations
    Unmatched statement boolean contains=s.contains(item); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    11
    boolean contains = s.contains(item);
    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 (9)
    Row Violation
    1Unmatched statement s.persist(item); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Expression a.setData("Anna") is a void method call, and thus it cannot be parameterized
    3Expression assertFalse("expecting removed entity to not be contained",contains) is a void method call, and thus it cannot be parameterized
    4Expression a.setData("Anna") is a void method call, and thus it cannot be parameterized
    5Expression assertFalse("expecting removed entity to not be contained",contains) is a void method call, and thus it cannot be parameterized
    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
    7Unmatched statement modifyEntity(a); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    8Unmatched statement boolean contains=s.contains(item); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    9Unmatched 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