Integer cached = ( Integer ) columnNameToIndexCache.get( columnName ); if ( cached != null ) { return cached.intValue(); } else { int index = rs.getTarget().findColumn( columnName ); columnNameToIndexCache.put( columnName, new Integer(index) ); return index; }
if ( FieldInterceptionHelper.isInstrumented( entity ) ) { FieldInterceptor interceptor = FieldInterceptionHelper.extractFieldInterceptor( entity ); if ( interceptor != null ) { interceptor.setSession( session ); } else { FieldInterceptor fieldInterceptor = FieldInterceptionHelper.injectFieldInterceptor( entity, getEntityName(), null, session ); fieldInterceptor.dirty(); } }
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/jdbc/ColumnNameCache.java File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java
Method name: int getIndexForColumnName(String, ResultSetWrapper) Method name: void afterReassociate(Object, SessionImplementor)
Number of AST nodes: 6 Number of AST nodes: 6
1
Integer cached = ( Integer ) columnNameToIndexCache.get( columnName
1
if ( FieldInterceptionHelper.isInstrumented( entity ) ) {
2
 );
2
			FieldInterceptor interceptor = FieldInterceptionHelper.extractFieldInterceptor( entity );
3
		if ( cached != null ) {
3
			if ( interceptor != null ) {
4
			return cached.intValue();
4
				interceptor.setSession( session );
5
		}
5
			}
6
		else {
6
			else {
7
			int index = rs.getTarget().findColumn( columnName );
7
				
8
			columnNameToIndexCache.put( columnName, new Integer(index) 
8
FieldInterceptor fieldInterceptor = FieldInterceptionHelper.injectFieldInterceptor(
9
						entity,
10
						getEntityName(),
11
						null,
12
						session
9
);
13
				);
10
			return index;
14
				fieldInterceptor.dirty();
15
			}
11
		}
16
		}
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
Number of node comparisons21
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements1
    Number of unmapped statements in the first code fragment5
    Number of unmapped statements in the second code fragment4
    Time elapsed for statement mapping (ms)1.9
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    1
    Integer cached = (Integer)columnNameToIndexCache.get(columnName);
                                                                                                                                        
                                                                                                                                                                                    
    2
    FieldInterceptor interceptor = FieldInterceptionHelper.extractFieldInterceptor(entity);
    2
    if (cached != null)
    2
    if (cached != null)
    3
    if (interceptor != null)
    Differences
    Expression1Expression2Difference
    cachedinterceptorVARIABLE_NAME_MISMATCH
    java.lang.Integerorg.hibernate.intercept.FieldInterceptorVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.lang.Integer of variable cached does not match with type org.hibernate.intercept.FieldInterceptor of variable interceptor
    • Make classes java.lang.Integer and org.hibernate.intercept.FieldInterceptor extend a common superclass
    3
    if (interceptor != null)
    3
    return cached.intValue();
    3
    return cached.intValue();
    Preondition Violations
    Unmatched statement return cached.intValue(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    Unmatched return cached.intValue();
                                                            
    else
            
    4
    int index = rs.getTarget().findColumn(columnName);
    4
    int index = rs.getTarget().findColumn(columnName);
    Preondition Violations
    Unmatched statement int index=rs.getTarget().findColumn(columnName); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
                                                                                                          
                                                                                                                                                                                                                                                      
    5
    FieldInterceptor fieldInterceptor = FieldInterceptionHelper.injectFieldInterceptor(entity, getEntityName(), null, session);
    5
    columnNameToIndexCache.put(columnName, new Integer(index));
                                                                                                                              
                                                            
    6
    fieldInterceptor.dirty();
    Preondition Violations
    Unmatched statement fieldInterceptor.dirty(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    6
    fieldInterceptor.dirty();
    6
    return index;
    6
    return index;
    Preondition Violations
    Unmatched return index;
                                    
                                                                          
    4
    interceptor.setSession(session);
    Preondition Violations
    Unmatched statement interceptor.setSession(session); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    4
    interceptor.setSession(session);
    Precondition Violations (8)
    Row Violation
    1Type java.lang.Integer of variable cached does not match with type org.hibernate.intercept.FieldInterceptor of variable interceptor
    2Unmatched statement return cached.intValue(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    3Unmatched return cached.intValue();
    4Unmatched statement int index=rs.getTarget().findColumn(columnName); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
    5Unmatched statement fieldInterceptor.dirty(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    6Unmatched return index;
    7Unmatched statement interceptor.setSession(session); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    8The refactoring of the clones is infeasible, because the number of macthed statements is equal to zero