while ( entries.hasNext() ) { Map.Entry entry = (Map.Entry) entries.next(); if (entry.getValue() instanceof ArrayList) { ArrayList list = (ArrayList) entry.getValue(); entry.setValue( list.toArray( new String[ list.size() ] ) ); } }
while ( criterionIterator.hasNext() ) { CriteriaImpl.CriterionEntry entry = ( CriteriaImpl.CriterionEntry ) criterionIterator.next(); String sqlString = entry.getCriterion().toSqlString( entry.getCriteria(), this ); condition.append( sqlString ); if ( criterionIterator.hasNext() ) { condition.append( " and " ); } }
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/cfg/ResultSetMappingBinder.java File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/loader/criteria/CriteriaQueryTranslator.java
Method name: java.util.Map bindPropertyResults(String, Element, PersistentClass, Mappings) Method name: String getWhereCondition()
Number of AST nodes: 5 Number of AST nodes: 6
1
while ( entries.hasNext() ) {
1
while ( criterionIterator.hasNext() ) {
2
			Map.Entry entry = (Map.Entry) entries.next();
2
			CriteriaImpl.CriterionEntry entry = ( CriteriaImpl.CriterionEntry ) 
3
			if (entry.getValue() instanceof ArrayList) {
4
				ArrayList list = (ArrayList) entry.getValue(
3
criterionIterator.next();
5
);
4
			String sqlString = entry.getCriterion().toSqlString( entry.getCriteria(), this );
6
				entry.setValue( list.toArray( new String[ list.size() ] )
5
			condition.append( sqlString );
6
			if ( criterionIterator.hasNext() ) {
7
 );
7
				condition.append( " and " );
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
Number of node comparisons14
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements2
    Number of unmapped statements in the first code fragment3
    Number of unmapped statements in the second code fragment4
    Time elapsed for statement mapping (ms)3.0
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    71
    while (entries.hasNext())
    71
    while (entries.hasNext())
    3
    while (criterionIterator.hasNext())
    Differences
    Expression1Expression2Difference
    entriescriterionIteratorVARIABLE_NAME_MISMATCH
    3
    while (criterionIterator.hasNext())
                                                                                                                                                                                          
    4
    CriteriaImpl.CriterionEntry entry = (CriteriaImpl.CriterionEntry)criterionIterator.next();
    Preondition Violations
    Unmatched statement CriteriaImpl.CriterionEntry entry=(CriteriaImpl.CriterionEntry)criterionIterator.next(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4
    CriteriaImpl.CriterionEntry entry = (CriteriaImpl.CriterionEntry)criterionIterator.next();
                                                                                                                                                                  
    5
    String sqlString = entry.getCriterion().toSqlString(entry.getCriteria(), this);
    Preondition Violations
    Unmatched statement String sqlString=entry.getCriterion().toSqlString(entry.getCriteria(),this); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched statement String sqlString=entry.getCriterion().toSqlString(entry.getCriteria(),this); 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
    String sqlString = entry.getCriterion().toSqlString(entry.getCriteria(), this);
                                                                  
    6
    condition.append(sqlString);
    72
    Map.Entry entry = (Map.Entry)entries.next();
    72
    Map.Entry entry = (Map.Entry)entries.next();
    Preondition Violations
    Unmatched statement Map.Entry entry=(Map.Entry)entries.next(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                
    73
    if (entry.getValue() instanceof ArrayList)
    73
    if (entry.getValue() instanceof ArrayList)
    7
    if (criterionIterator.hasNext())
    Differences
    Expression1Expression2Difference
    entry.getValue() instanceof ArrayListcriterionIterator.hasNext()TYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression entry.getValue() instanceof ArrayList cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7
    if (criterionIterator.hasNext())
                                                              
    8
    condition.append(" and ");
    74
    ArrayList list = (ArrayList)entry.getValue();
    74
    ArrayList list = (ArrayList)entry.getValue();
    Preondition Violations
    Unmatched statement ArrayList list=(ArrayList)entry.getValue(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                  
    75
    entry.setValue(list.toArray(new String[list.size()]));
    75
    entry.setValue(list.toArray(new String[list.size()]));
    Preondition Violations
    Unmatched statement entry.setValue(list.toArray(new String[list.size()])); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                                                                        
    Precondition Violations (7)
    Row Violation
    1Unmatched statement CriteriaImpl.CriterionEntry entry=(CriteriaImpl.CriterionEntry)criterionIterator.next(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched statement String sqlString=entry.getCriterion().toSqlString(entry.getCriteria(),this); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Unmatched statement String sqlString=entry.getCriterion().toSqlString(entry.getCriteria(),this); 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
    4Unmatched statement Map.Entry entry=(Map.Entry)entries.next(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5Expression entry.getValue() instanceof ArrayList cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Unmatched statement ArrayList list=(ArrayList)entry.getValue(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    7Unmatched statement entry.setValue(list.toArray(new String[list.size()])); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted