CollectionListeners listeners = new CollectionListeners( getSessions() ); ParentWithCollection parent = createParentWithNullChildren( "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 );
CollectionListeners listeners = new CollectionListeners( getSessions() ); ParentWithCollection parent = createParentWithNullChildren( "parent" ); assertNull( parent.getChildren() ); int index = 0; // pre- and post- collection recreate events should be created when creating an entity with a "null" collection 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 );
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/BrokenCollectionEventTest.java
Method name: void testDeleteParentWithNullChildren() Method name: void testSaveParentNullChildrenFailureExpected()
Number of AST nodes: 14 Number of AST nodes: 15
1
CollectionListeners listeners = new CollectionListeners( getSessions() );
1
CollectionListeners listeners = new CollectionListeners( getSessions() );
2
		ParentWithCollection parent = createParentWithNullChildren( "parent" );
2
		ParentWithCollection parent = createParentWithNullChildren( "parent" );
3
		listeners.clear();
3
		
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();
9
		s.close();
10
		int index = 0;
4
assertNull( parent.getChildren() );
5
		int index = 0;
6
		// pre- and post- collection recreate events should be created when creating an entity with a "null" collection
11
		checkResult( listeners, listeners.getInitializeCollectionListener(), parent, index++ );
7
		checkResult( listeners, listeners.getPreCollectionRecreateListener(), parent, index++ );
12
		checkResult( listeners, listeners.getPreCollectionRemoveListener(), parent, index++ );
8
		checkResult( listeners, listeners.getPostCollectionRecreateListener(), parent, index++ );
13
		checkResult( listeners, listeners.getPostCollectionRemoveListener(), parent, index++
9
		checkNumberOfResults( listeners, index );
10
		listeners.clear();
11
		Session s = openSession();
12
		Transaction tx = s.beginTransaction();
13
		parent = ( ParentWithCollection ) s.get( parent.getClass(), parent.getId() );
14
		tx.commit();
15
		s.close();
14
 );
16
		assertNotNull( parent.getChildren() );
15
		checkNumberOfResults( listeners, index );
17
		checkNumberOfResults( listeners, 0 );
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 comparisons139
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements14
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment1
    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 = createParentWithNullChildren("parent");
    2
    ParentWithCollection parent = createParentWithNullChildren("parent");
                                                                            
    3
    assertNull(parent.getChildren());
    Preondition Violations
    Unmatched statement assertNull(parent.getChildren()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3
    assertNull(parent.getChildren());
    3
    listeners.clear();
    8
    listeners.clear();
    4
    Session s = openSession();
    9
    Session s = openSession();
    5
    Transaction tx = s.beginTransaction();
    10
    Transaction tx = s.beginTransaction();
    6
    parent = (ParentWithCollection)s.get(parent.getClass(), parent.getId());
    11
    parent = (ParentWithCollection)s.get(parent.getClass(), parent.getId());
    7
    s.delete(parent);
    7
    s.delete(parent);
    15
    checkNumberOfResults(listeners, 0);
    Differences
    Expression1Expression2Difference
    deletecheckNumberOfResultsMETHOD_INVOCATION_NAME_MISMATCH
    s.delete(parent)checkNumberOfResults(listeners,0)ARGUMENT_NUMBER_MISMATCH
    sMISSING_METHOD_INVOCATION_EXPRESSION
    Preondition Violations
    Expression s.delete(parent) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression checkNumberOfResults(listeners,0) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    • Inline private method checkNumberOfResults
    Expression s.delete(parent) is a void method call, and thus it cannot be parameterized
    Expression checkNumberOfResults(listeners,0) is a void method call, and thus it cannot be parameterized
    Expression s.delete(parent) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression checkNumberOfResults(listeners,0) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    • Inline private method checkNumberOfResults
    Expression s.delete(parent) is a void method call, and thus it cannot be parameterized
    Expression checkNumberOfResults(listeners,0) is a void method call, and thus it cannot be parameterized
    15
    checkNumberOfResults(listeners, 0);
    8
    tx.commit();
    12
    tx.commit();
    9
    s.close();
    13
    s.close();
    10
    int index = 0;
    4
    int index = 0;
    11
    checkResult(listeners, listeners.getInitializeCollectionListener(), parent, index++);
    11
    checkResult(listeners, listeners.getInitializeCollectionListener(), parent, index++);
    5
    checkResult(listeners, listeners.getPreCollectionRecreateListener(), parent, index++);
    Differences
    Expression1Expression2Difference
    getInitializeCollectionListenergetPreCollectionRecreateListenerMETHOD_INVOCATION_NAME_MISMATCH
    org.hibernate.test.event.collection.CollectionListeners.InitializeCollectionListenerorg.hibernate.test.event.collection.CollectionListeners.PreCollectionRecreateListenerVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Expression listeners.getInitializeCollectionListener() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression listeners.getPreCollectionRecreateListener() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Type org.hibernate.test.event.collection.CollectionListeners.InitializeCollectionListener of variable listeners.getInitializeCollectionListener() does not match with type org.hibernate.test.event.collection.CollectionListeners.PreCollectionRecreateListener of variable listeners.getPreCollectionRecreateListener()
    • Make classes org.hibernate.test.event.collection.CollectionListeners.InitializeCollectionListener and org.hibernate.test.event.collection.CollectionListeners.PreCollectionRecreateListener extend a common superclass
    5
    checkResult(listeners, listeners.getPreCollectionRecreateListener(), parent, index++);
    12
    checkResult(listeners, listeners.getPreCollectionRemoveListener(), parent, index++);
    12
    checkResult(listeners, listeners.getPreCollectionRemoveListener(), parent, index++);
    6
    checkResult(listeners, listeners.getPostCollectionRecreateListener(), parent, index++);
    Differences
    Expression1Expression2Difference
    getPreCollectionRemoveListenergetPostCollectionRecreateListenerMETHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Expression listeners.getPreCollectionRemoveListener() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression listeners.getPostCollectionRecreateListener() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6
    checkResult(listeners, listeners.getPostCollectionRecreateListener(), parent, index++);
    13
    checkResult(listeners, listeners.getPostCollectionRemoveListener(), parent, index++);
    13
    checkResult(listeners, listeners.getPostCollectionRemoveListener(), parent, index++);
    7
    checkNumberOfResults(listeners, index);
    Differences
    Expression1Expression2Difference
    checkResultcheckNumberOfResultsMETHOD_INVOCATION_NAME_MISMATCH
    checkResult(listeners,listeners.getPostCollectionRemoveListener(),parent,index++)checkNumberOfResults(listeners,index)ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    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) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    • Inline private method checkNumberOfResults
    Expression checkResult(listeners,listeners.getPostCollectionRemoveListener(),parent,index++) is a void method call, and thus it cannot be parameterized
    Expression checkNumberOfResults(listeners,index) is a void method call, and thus it cannot be parameterized
    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) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    • Inline private method checkNumberOfResults
    Expression checkResult(listeners,listeners.getPostCollectionRemoveListener(),parent,index++) is a void method call, and thus it cannot be parameterized
    Expression checkNumberOfResults(listeners,index) is a void method call, and thus it cannot be parameterized
    7
    checkNumberOfResults(listeners, index);
    14
    checkNumberOfResults(listeners, index);
    14
    checkNumberOfResults(listeners, index);
    14
    assertNotNull(parent.getChildren());
    Differences
    Expression1Expression2Difference
    checkNumberOfResultsassertNotNullMETHOD_INVOCATION_NAME_MISMATCH
    checkNumberOfResults(listeners,index)assertNotNull(parent.getChildren())ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression checkNumberOfResults(listeners,index) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertNotNull(parent.getChildren()) 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 assertNotNull(parent.getChildren()) 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 assertNotNull(parent.getChildren()) 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 assertNotNull(parent.getChildren()) is a void method call, and thus it cannot be parameterized
    14
    assertNotNull(parent.getChildren());
    Precondition Violations (31)
    Row Violation
    1Unmatched statement assertNull(parent.getChildren()); cannot be moved before or after the extracted code, 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 checkNumberOfResults(listeners,0) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression s.delete(parent) is a void method call, and thus it cannot be parameterized
    5Expression checkNumberOfResults(listeners,0) is a void method call, and thus it cannot be parameterized
    6Expression s.delete(parent) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7Expression checkNumberOfResults(listeners,0) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8Expression s.delete(parent) is a void method call, and thus it cannot be parameterized
    9Expression checkNumberOfResults(listeners,0) is a void method call, and thus it cannot be parameterized
    10Expression listeners.getInitializeCollectionListener() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    11Expression listeners.getPreCollectionRecreateListener() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    12Type org.hibernate.test.event.collection.CollectionListeners.InitializeCollectionListener of variable listeners.getInitializeCollectionListener() does not match with type org.hibernate.test.event.collection.CollectionListeners.PreCollectionRecreateListener of variable listeners.getPreCollectionRecreateListener()
    13Expression listeners.getPreCollectionRemoveListener() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    14Expression listeners.getPostCollectionRecreateListener() 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) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    17Expression checkResult(listeners,listeners.getPostCollectionRemoveListener(),parent,index++) is a void method call, and thus it cannot be parameterized
    18Expression checkNumberOfResults(listeners,index) is a void method call, and thus it cannot be parameterized
    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) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    21Expression checkResult(listeners,listeners.getPostCollectionRemoveListener(),parent,index++) is a void method call, and thus it cannot be parameterized
    22Expression checkNumberOfResults(listeners,index) is a void method call, and thus it cannot be parameterized
    23Expression checkNumberOfResults(listeners,index) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    24Expression assertNotNull(parent.getChildren()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    25Expression checkNumberOfResults(listeners,index) is a void method call, and thus it cannot be parameterized
    26Expression assertNotNull(parent.getChildren()) is a void method call, and thus it cannot be parameterized
    27Expression checkNumberOfResults(listeners,index) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    28Expression assertNotNull(parent.getChildren()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    29Expression checkNumberOfResults(listeners,index) is a void method call, and thus it cannot be parameterized
    30Expression assertNotNull(parent.getChildren()) is a void method call, and thus it cannot be parameterized
    31Clone fragment #1 returns variables , while Clone fragment #2 returns variables parent