PostCollectionRecreateEventListener[] postListeners = getSession().getListeners() .getPostCollectionRecreateEventListeners(); if (postListeners.length > 0) { PostCollectionRecreateEvent postEvent = new PostCollectionRecreateEvent( getPersister(), getCollection(), ( EventSource ) getSession() ); for ( int i = 0; i < postListeners.length; i++ ) { postListeners[i].onPostRecreateCollection( postEvent ); } }
PreCollectionUpdateEventListener[] preListeners = getSession().getListeners() .getPreCollectionUpdateEventListeners(); if (preListeners.length > 0) { PreCollectionUpdateEvent preEvent = new PreCollectionUpdateEvent( getPersister(), getCollection(), ( EventSource ) getSession() ); for ( int i = 0; i < preListeners.length; i++ ) { preListeners[i].onPreUpdateCollection( preEvent ); } }
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/action/CollectionRecreateAction.java File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/action/CollectionUpdateAction.java
Method name: void postRecreate() Method name: void preUpdate()
Number of AST nodes: 5 Number of AST nodes: 5
1
PostCollectionRecreateEventListener[] postListeners = getSession().getListeners()
1
PreCollectionUpdateEventListener[] preListeners = getSession().getListeners()
2
				.getPostCollectionRecreateEventListeners();
2
				.getPreCollectionUpdateEventListeners();
3
		if (postListeners.length > 0) {
3
		if (preListeners.length > 0) {
4
			PostCollectionRecreateEvent postEvent = new PostCollectionRecreateEvent(
4
			PreCollectionUpdateEvent preEvent = new PreCollectionUpdateEvent(
5
					getPersister(), getCollection(), ( EventSource ) getSession() );
5
					getPersister(), getCollection(), ( EventSource ) getSession() );
6
			for ( int i = 0; i < postListeners.length; i++ ) {
6
			for ( int i = 0; i < preListeners.length; i++ ) {
7
				postListeners[i].onPostRecreateCollection( postEvent );
7
				preListeners[i].onPreUpdateCollection( preEvent );
8
			}
8
			}
9
		}
9
		}
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.2
Clones locationClones are in different classes having the same super class
Number of node comparisons9
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements3
    Number of unmapped statements in the first code fragment2
    Number of unmapped statements in the second code fragment2
    Time elapsed for statement mapping (ms)1.2
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
                                                                                                                                                                                                                                                
    1
    PreCollectionUpdateEventListener[] preListeners = getSession().getListeners().getPreCollectionUpdateEventListeners();
    1
    PostCollectionRecreateEventListener[] postListeners = getSession().getListeners().getPostCollectionRecreateEventListeners();
                                                                                                                                                                                                                                                              
    2
    if (postListeners.length > 0)
    2
    if (postListeners.length > 0)
    2
    if (preListeners.length > 0)
    Differences
    Expression1Expression2Difference
    postListenerspreListenersVARIABLE_NAME_MISMATCH
    org.hibernate.event.PostCollectionRecreateEventListener[]org.hibernate.event.PreCollectionUpdateEventListener[]VARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.event.PostCollectionRecreateEventListener[] of variable postListeners does not match with type org.hibernate.event.PreCollectionUpdateEventListener[] of variable preListeners
    • Make classes org.hibernate.event.PostCollectionRecreateEventListener[] and org.hibernate.event.PreCollectionUpdateEventListener[] extend a common superclass
    2
    if (preListeners.length > 0)
    3
    PostCollectionRecreateEvent postEvent = new PostCollectionRecreateEvent(getPersister(), getCollection(), (EventSource)getSession());
    3
    PostCollectionRecreateEvent postEvent = new PostCollectionRecreateEvent(getPersister(), getCollection(), (EventSource)getSession());
    3
    PreCollectionUpdateEvent preEvent = new PreCollectionUpdateEvent(getPersister(), getCollection(), (EventSource)getSession());
    Differences
    Expression1Expression2Difference
    org.hibernate.event.PostCollectionRecreateEventorg.hibernate.event.PreCollectionUpdateEventSUBCLASS_TYPE_MISMATCH
    postEventpreEventVARIABLE_NAME_MISMATCH
    org.hibernate.event.PostCollectionRecreateEventorg.hibernate.event.PreCollectionUpdateEventSUBCLASS_TYPE_MISMATCH
    org.hibernate.event.PostCollectionRecreateEventorg.hibernate.event.PreCollectionUpdateEventSUBCLASS_TYPE_MISMATCH
    3
    PreCollectionUpdateEvent preEvent = new PreCollectionUpdateEvent(getPersister(), getCollection(), (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 < preListeners.length; i++)
    Differences
    Expression1Expression2Difference
    postListenerspreListenersVARIABLE_NAME_MISMATCH
    org.hibernate.event.PostCollectionRecreateEventListener[]org.hibernate.event.PreCollectionUpdateEventListener[]VARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.event.PostCollectionRecreateEventListener[] of variable postListeners does not match with type org.hibernate.event.PreCollectionUpdateEventListener[] of variable preListeners
    • Make classes org.hibernate.event.PostCollectionRecreateEventListener[] and org.hibernate.event.PreCollectionUpdateEventListener[] extend a common superclass
    4
    for (int i = 0; i < preListeners.length; i++)
                                                                                                          
    5
    preListeners[i].onPreUpdateCollection(preEvent);
    Preondition Violations
    Unmatched statement preListeners[i].onPreUpdateCollection(preEvent); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5
    preListeners[i].onPreUpdateCollection(preEvent);
    5
    postListeners[i].onPostRecreateCollection(postEvent);
    5
    postListeners[i].onPostRecreateCollection(postEvent);
    Preondition Violations
    Unmatched statement postListeners[i].onPostRecreateCollection(postEvent); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                                    
    Precondition Violations (5)
    Row Violation
    1Type org.hibernate.event.PostCollectionRecreateEventListener[] of variable postListeners does not match with type org.hibernate.event.PreCollectionUpdateEventListener[] of variable preListeners
    2Type org.hibernate.event.PostCollectionRecreateEventListener[] of variable postListeners does not match with type org.hibernate.event.PreCollectionUpdateEventListener[] of variable preListeners
    3Unmatched statement preListeners[i].onPreUpdateCollection(preEvent); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4Unmatched statement postListeners[i].onPostRecreateCollection(postEvent); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5Clone fragment #1 returns variables postEvent, i , while Clone fragment #2 returns variables preEvent, i