CollectionListeners listeners = new CollectionListeners( getSessions() ); ParentWithCollection parent = createParentWithNoChildren( "parent" ); assertEquals( 0, parent.getChildren().size() ); int index = 0; checkResult( listeners, listeners.getPreCollectionRecreateListener(), parent, index++ ); checkResult( listeners, listeners.getPostCollectionRecreateListener(), parent, index++ ); checkNumberOfResults( listeners, index ); listeners.clear(); Session s = openSession(); Transaction tx = s.beginTransaction(); parent = ( ParentWithCollection ) s.get( parent.getClass(), parent.getId() ); tx.commit(); s.close(); assertNotNull( parent.getChildren() ); checkNumberOfResults( listeners, 0 );
CollectionListeners listeners = new CollectionListeners( getSessions() ); ParentWithCollection parent = createParentWithNoChildren( "parent" ); listeners.clear(); Session s = openSession(); Transaction tx = s.beginTransaction(); parent = ( ParentWithCollection ) s.get( parent.getClass(), parent.getId() ); s.delete( parent ); tx.commit(); s.close(); int index = 0; checkResult( listeners, listeners.getInitializeCollectionListener(), parent, index++ ); checkResult( listeners, listeners.getPreCollectionRemoveListener(), parent, index++ ); checkResult( listeners, listeners.getPostCollectionRemoveListener(), parent, index++ ); checkNumberOfResults( listeners, index );
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/event/collection/AbstractCollectionEventTest.java File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/event/collection/AbstractCollectionEventTest.java
Method name: void testSaveParentEmptyChildren() Method name: void testDeleteParentWithNoChildren()
Number of AST nodes: 15 Number of AST nodes: 14
1
CollectionListeners listeners = new CollectionListeners( getSessions() );
1
CollectionListeners listeners = new CollectionListeners( getSessions() );
2
		ParentWithCollection parent = createParentWithNoChildren( "parent" );
2
		ParentWithCollection parent = createParentWithNoChildren( "parent" );
3
		assertEquals( 0, parent.getChildren().size() 
3
		listeners.clear();
4
		Session s = openSession();
5
		Transaction tx = s.beginTransaction();
6
		parent = ( ParentWithCollection ) s.get( parent.getClass(), parent.getId() );
7
		s.delete( parent );
8
		tx.commit();
4
);
9
		s.close();
5
		int index = 0;
10
		int index = 0;
6
		checkResult( listeners, listeners.getPreCollectionRecreateListener(), parent, index++ );
11
		checkResult( listeners, listeners.getInitializeCollectionListener(), parent, index++ );
7
		checkResult( listeners, listeners.getPostCollectionRecreateListener(), parent, index++ );
12
		checkResult( listeners, listeners.getPreCollectionRemoveListener(), parent, index++ );
8
		checkNumberOfResults( listeners, index );
13
		checkResult( listeners, 
9
		listeners.clear();
10
		Session s = openSession();
11
		Transaction tx = s.beginTransaction();
12
		parent = ( ParentWithCollection ) s.get( parent.getClass(), parent.getId() );
13
		tx.commit();
14
		s.close();
15
		assertNotNull( parent.getChildren() );
14
listeners.getPostCollectionRemoveListener(), parent, index++ );
16
		checkNumberOfResults( listeners, 0 );
15
		checkNumberOfResults( listeners, index );
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 declared in the same class
Number of node comparisons139
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements14
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)0.0
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    1
    CollectionListeners listeners = new CollectionListeners(getSessions());
    1
    CollectionListeners listeners = new CollectionListeners(getSessions());
    2
    ParentWithCollection parent = createParentWithNoChildren("parent");
    2
    ParentWithCollection parent = createParentWithNoChildren("parent");
    3
    assertEquals(0, parent.getChildren().size());
    3
    assertEquals(0, parent.getChildren().size());
    7
    s.delete(parent);
    Differences
    Expression1Expression2Difference
    assertEqualsdeleteMETHOD_INVOCATION_NAME_MISMATCH
    assertEquals(0,parent.getChildren().size())s.delete(parent)ARGUMENT_NUMBER_MISMATCH
    sMISSING_METHOD_INVOCATION_EXPRESSION
    Preondition Violations
    Expression assertEquals(0,parent.getChildren().size()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression s.delete(parent) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertEquals(0,parent.getChildren().size()) is a void method call, and thus it cannot be parameterized
    Expression s.delete(parent) is a void method call, and thus it cannot be parameterized
    Expression assertEquals(0,parent.getChildren().size()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression s.delete(parent) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertEquals(0,parent.getChildren().size()) is a void method call, and thus it cannot be parameterized
    Expression s.delete(parent) is a void method call, and thus it cannot be parameterized
    7
    s.delete(parent);
    4
    int index = 0;
    10
    int index = 0;
    5
    checkResult(listeners, listeners.getPreCollectionRecreateListener(), parent, index++);
    5
    checkResult(listeners, listeners.getPreCollectionRecreateListener(), parent, index++);
    11
    checkResult(listeners, listeners.getInitializeCollectionListener(), parent, index++);
    Differences
    Expression1Expression2Difference
    getPreCollectionRecreateListenergetInitializeCollectionListenerMETHOD_INVOCATION_NAME_MISMATCH
    org.hibernate.test.event.collection.CollectionListeners.PreCollectionRecreateListenerorg.hibernate.test.event.collection.CollectionListeners.InitializeCollectionListenerVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Expression listeners.getPreCollectionRecreateListener() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression listeners.getInitializeCollectionListener() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Type org.hibernate.test.event.collection.CollectionListeners.PreCollectionRecreateListener of variable listeners.getPreCollectionRecreateListener() does not match with type org.hibernate.test.event.collection.CollectionListeners.InitializeCollectionListener of variable listeners.getInitializeCollectionListener()
    • Make classes org.hibernate.test.event.collection.CollectionListeners.PreCollectionRecreateListener and org.hibernate.test.event.collection.CollectionListeners.InitializeCollectionListener extend a common superclass
    11
    checkResult(listeners, listeners.getInitializeCollectionListener(), parent, index++);
    6
    checkResult(listeners, listeners.getPostCollectionRecreateListener(), parent, index++);
    6
    checkResult(listeners, listeners.getPostCollectionRecreateListener(), parent, index++);
    12
    checkResult(listeners, listeners.getPreCollectionRemoveListener(), parent, index++);
    Differences
    Expression1Expression2Difference
    getPostCollectionRecreateListenergetPreCollectionRemoveListenerMETHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Expression listeners.getPostCollectionRecreateListener() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression listeners.getPreCollectionRemoveListener() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    12
    checkResult(listeners, listeners.getPreCollectionRemoveListener(), parent, index++);
    7
    checkNumberOfResults(listeners, index);
    7
    checkNumberOfResults(listeners, index);
    13
    checkResult(listeners, listeners.getPostCollectionRemoveListener(), parent, index++);
    Differences
    Expression1Expression2Difference
    checkNumberOfResultscheckResultMETHOD_INVOCATION_NAME_MISMATCH
    checkNumberOfResults(listeners,index)checkResult(listeners,listeners.getPostCollectionRemoveListener(),parent,index++)ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression checkNumberOfResults(listeners,index) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression checkResult(listeners,listeners.getPostCollectionRemoveListener(),parent,index++) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression checkNumberOfResults(listeners,index) is a void method call, and thus it cannot be parameterized
    Expression checkResult(listeners,listeners.getPostCollectionRemoveListener(),parent,index++) is a void method call, and thus it cannot be parameterized
    Expression checkNumberOfResults(listeners,index) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression checkResult(listeners,listeners.getPostCollectionRemoveListener(),parent,index++) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression checkNumberOfResults(listeners,index) is a void method call, and thus it cannot be parameterized
    Expression checkResult(listeners,listeners.getPostCollectionRemoveListener(),parent,index++) is a void method call, and thus it cannot be parameterized
    13
    checkResult(listeners, listeners.getPostCollectionRemoveListener(), parent, index++);
    8
    listeners.clear();
    3
    listeners.clear();
    9
    Session s = openSession();
    4
    Session s = openSession();
    10
    Transaction tx = s.beginTransaction();
    5
    Transaction tx = s.beginTransaction();
    11
    parent = (ParentWithCollection)s.get(parent.getClass(), parent.getId());
    6
    parent = (ParentWithCollection)s.get(parent.getClass(), parent.getId());
    12
    tx.commit();
    8
    tx.commit();
    13
    s.close();
    9
    s.close();
    14
    assertNotNull(parent.getChildren());
                                                                                    
    15
    checkNumberOfResults(listeners, 0);
    15
    checkNumberOfResults(listeners, 0);
    14
    checkNumberOfResults(listeners, index);
    Differences
    Expression1Expression2Difference
    0indexTYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression index cannot be parameterized, because it has dependencies to/from statements that will be extracted
    14
    checkNumberOfResults(listeners, index);
    Precondition Violations (23)
    Row Violation
    1Expression assertEquals(0,parent.getChildren().size()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression s.delete(parent) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression assertEquals(0,parent.getChildren().size()) is a void method call, and thus it cannot be parameterized
    4Expression s.delete(parent) is a void method call, and thus it cannot be parameterized
    5Expression assertEquals(0,parent.getChildren().size()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Expression s.delete(parent) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7Expression assertEquals(0,parent.getChildren().size()) is a void method call, and thus it cannot be parameterized
    8Expression s.delete(parent) is a void method call, and thus it cannot be parameterized
    9Expression listeners.getPreCollectionRecreateListener() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    10Expression listeners.getInitializeCollectionListener() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    11Type org.hibernate.test.event.collection.CollectionListeners.PreCollectionRecreateListener of variable listeners.getPreCollectionRecreateListener() does not match with type org.hibernate.test.event.collection.CollectionListeners.InitializeCollectionListener of variable listeners.getInitializeCollectionListener()
    12Expression listeners.getPostCollectionRecreateListener() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    13Expression listeners.getPreCollectionRemoveListener() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    14Expression checkNumberOfResults(listeners,index) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    15Expression checkResult(listeners,listeners.getPostCollectionRemoveListener(),parent,index++) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    16Expression checkNumberOfResults(listeners,index) is a void method call, and thus it cannot be parameterized
    17Expression checkResult(listeners,listeners.getPostCollectionRemoveListener(),parent,index++) is a void method call, and thus it cannot be parameterized
    18Expression checkNumberOfResults(listeners,index) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    19Expression checkResult(listeners,listeners.getPostCollectionRemoveListener(),parent,index++) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    20Expression checkNumberOfResults(listeners,index) is a void method call, and thus it cannot be parameterized
    21Expression checkResult(listeners,listeners.getPostCollectionRemoveListener(),parent,index++) is a void method call, and thus it cannot be parameterized
    22Expression index cannot be parameterized, because it has dependencies to/from statements that will be extracted
    23Clone fragment #1 returns variables parent , while Clone fragment #2 returns variables