PostCollectionRemoveEventListener[] postListeners = getSession().getListeners() .getPostCollectionRemoveEventListeners(); if (postListeners.length>0) { PostCollectionRemoveEvent postEvent = new PostCollectionRemoveEvent( getPersister(), getCollection(), ( EventSource ) getSession(), affectedOwner ); for ( int i = 0; i < postListeners.length; i++ ) { postListeners[i].onPostRemoveCollection(postEvent); } }
PostDeleteEventListener[] postListeners = getSession().getListeners() .getPostCommitDeleteEventListeners(); if (postListeners.length>0) { PostDeleteEvent postEvent = new PostDeleteEvent( getInstance(), getId(), state, getPersister(), (EventSource) getSession() ); for ( int i = 0; i < postListeners.length; i++ ) { postListeners[i].onPostDelete(postEvent); } }
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/action/CollectionRemoveAction.java File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/action/EntityDeleteAction.java
Method name: void postRemove() Method name: void postCommitDelete()
Number of AST nodes: 5 Number of AST nodes: 5
1
PostCollectionRemoveEventListener[] postListeners = getSession().getListeners()
1
PostDeleteEventListener[] postListeners = getSession().getListeners()
2
				.getPostCollectionRemoveEventListeners();
2
				.getPostCommitDeleteEventListeners();
3
		if (postListeners.length>0) {
3
		if (postListeners.length>0) {
4
			PostCollectionRemoveEvent postEvent = new PostCollectionRemoveEvent(
4
			PostDeleteEvent postEvent = new PostDeleteEvent(
5
					getPersister(), getCollection(), ( 
5
					getInstance(),
6
					getId(),
7
					state,
8
					getPersister(),
6
EventSource ) getSession(), affectedOwner 
9
					(EventSource) getSession()
7
);
10
			);
8
			for ( int i = 0; i < postListeners.length; i++ ) {
11
			for ( int i = 0; i < postListeners.length; i++ ) {
9
				postListeners[i].onPostRemoveCollection(postEvent);
12
				postListeners[i].onPostDelete(postEvent);
10
			}
13
			}
11
		}
14
		}
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.3
Clones locationClones are in different classes
Number of node comparisons9
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements4
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)186.4
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
                                                                                                                                                                                                                          
    1
    PostDeleteEventListener[] postListeners = getSession().getListeners().getPostCommitDeleteEventListeners();
    1
    PostCollectionRemoveEventListener[] postListeners = getSession().getListeners().getPostCollectionRemoveEventListeners();
                                                                                                                                                                                                                                                      
    2
    if (postListeners.length > 0)
    2
    if (postListeners.length > 0)
    2
    if (postListeners.length > 0)
    Differences
    Expression1Expression2Difference
    org.hibernate.event.PostCollectionRemoveEventListener[]org.hibernate.event.PostDeleteEventListener[]VARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type int of variable postListeners.length does not match with type int of variable postListeners.length
    • Make classes org.hibernate.event.PostCollectionRemoveEventListener[] and org.hibernate.event.PostDeleteEventListener[] extend a common superclass
    2
    if (postListeners.length > 0)
    3
    PostCollectionRemoveEvent postEvent = new PostCollectionRemoveEvent(getPersister(), getCollection(), (EventSource)getSession(), affectedOwner);
    3
    PostCollectionRemoveEvent postEvent = new PostCollectionRemoveEvent(getPersister(), getCollection(), (EventSource)getSession(), affectedOwner);
    3
    PostDeleteEvent postEvent = new PostDeleteEvent(getInstance(), getId(), state, getPersister(), (EventSource)getSession());
    Differences
    Expression1Expression2Difference
    org.hibernate.event.PostCollectionRemoveEventorg.hibernate.event.PostDeleteEventSUBCLASS_TYPE_MISMATCH
    org.hibernate.event.PostCollectionRemoveEventorg.hibernate.event.PostDeleteEventSUBCLASS_TYPE_MISMATCH
    org.hibernate.event.PostCollectionRemoveEventorg.hibernate.event.PostDeleteEventSUBCLASS_TYPE_MISMATCH
    new PostCollectionRemoveEvent(getPersister(),getCollection(),(EventSource)getSession(),affectedOwner)new PostDeleteEvent(getInstance(),getId(),state,getPersister(),(EventSource)getSession())ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression new PostDeleteEvent(getInstance(),getId(),state,getPersister(),(EventSource)getSession()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression new PostDeleteEvent(getInstance(),getId(),state,getPersister(),(EventSource)getSession()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3
    PostDeleteEvent postEvent = new PostDeleteEvent(getInstance(), getId(), state, getPersister(), (EventSource)getSession());
    4
    for (int i = 0; i < postListeners.length; i++)
    4
    for (int i = 0; i < postListeners.length; i++)
    4
    for (int i = 0; i < postListeners.length; i++)
    Differences
    Expression1Expression2Difference
    org.hibernate.event.PostCollectionRemoveEventListener[]org.hibernate.event.PostDeleteEventListener[]VARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type int of variable postListeners.length does not match with type int of variable postListeners.length
    • Make classes org.hibernate.event.PostCollectionRemoveEventListener[] and org.hibernate.event.PostDeleteEventListener[] extend a common superclass
    4
    for (int i = 0; i < postListeners.length; i++)
    5
    postListeners[i].onPostRemoveCollection(postEvent);
    5
    postListeners[i].onPostRemoveCollection(postEvent);
    5
    postListeners[i].onPostDelete(postEvent);
    Differences
    Expression1Expression2Difference
    org.hibernate.event.PostCollectionRemoveEventorg.hibernate.event.PostDeleteEventSUBCLASS_TYPE_MISMATCH
    onPostRemoveCollectiononPostDeleteMETHOD_INVOCATION_NAME_MISMATCH
    org.hibernate.event.PostCollectionRemoveEventListener[]org.hibernate.event.PostDeleteEventListener[]VARIABLE_TYPE_MISMATCH
    Preondition Violations
    Expression postListeners[i].onPostRemoveCollection(postEvent) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression postListeners[i].onPostDelete(postEvent) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression postListeners[i].onPostRemoveCollection(postEvent) is a void method call, and thus it cannot be parameterized
    Expression postListeners[i].onPostDelete(postEvent) is a void method call, and thus it cannot be parameterized
    Type org.hibernate.event.PostCollectionRemoveEventListener[] of variable postListeners does not match with type org.hibernate.event.PostDeleteEventListener[] of variable postListeners
    • Make classes org.hibernate.event.PostCollectionRemoveEventListener[] and org.hibernate.event.PostDeleteEventListener[] extend a common superclass
    5
    postListeners[i].onPostDelete(postEvent);
    Precondition Violations (10)
    Row Violation
    1Type int of variable postListeners.length does not match with type int of variable postListeners.length
    2Expression new PostDeleteEvent(getInstance(),getId(),state,getPersister(),(EventSource)getSession()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression new PostDeleteEvent(getInstance(),getId(),state,getPersister(),(EventSource)getSession()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Type int of variable postListeners.length does not match with type int of variable postListeners.length
    5Expression postListeners[i].onPostRemoveCollection(postEvent) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Expression postListeners[i].onPostDelete(postEvent) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7Expression postListeners[i].onPostRemoveCollection(postEvent) is a void method call, and thus it cannot be parameterized
    8Expression postListeners[i].onPostDelete(postEvent) is a void method call, and thus it cannot be parameterized
    9Type org.hibernate.event.PostCollectionRemoveEventListener[] of variable postListeners does not match with type org.hibernate.event.PostDeleteEventListener[] of variable postListeners
    10The refactoring of the clones is infeasible, because classes org.hibernate.action.CollectionRemoveAction and org.hibernate.action.EntityDeleteAction do not have a common superclass