for ( int i = 0; i < tokens.length; i++ ) { buf.append( tokens[i] ); if ( !isSubselect ) { buf.append( " as " ) .append( NameGenerator.scalarName( c, i ) ); } if ( i != tokens.length - 1 ) buf.append( ", " ); }
for ( int i=0; i<tables.length; i++ ) { if (tables.length>1) { buf.append("select ").append(column).append(" from "); } buf.append( Table.qualify( catalog, schema, tables[i] ) ); if ( i<tables.length-1) buf.append(" union "); }
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/hql/classic/QueryTranslatorImpl.java File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/id/IncrementGenerator.java
Method name: String renderScalarSelect() Method name: void configure(Type, Properties, Dialect)
Number of AST nodes: 6 Number of AST nodes: 6
1
for ( int i = 0; i < tokens.length; i++ ) {
1
for ( int i=0; i<tables.length; i++ ) {
2
						buf.append( tokens[i] );
2
			
3
						if ( !isSubselect ) {
4
							buf
3
if (tables.length>1) {
5
.append( " as " )
4
				buf.append("select ").append(column).append(" from ");
6
			
5
			}
7
						.append( NameGenerator.scalarName( c, i ) );
6
			buf.append( 
8
						}
9
						if ( i != token
7
Table.qualify( catalog, schema, tables[i] ) );
10
s.length - 1 ) buf.append( ", " );
8
			if ( i<tables.length-1) buf.append(
11
			
9
" union ");
12
		}
10
		}
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.5
Clones locationClones are in different classes
Number of node comparisons15
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements4
    Number of unmapped statements in the first code fragment2
    Number of unmapped statements in the second code fragment2
    Time elapsed for statement mapping (ms)20.6
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    38
    for (int i = 0; i < tokens.length; i++)
    38
    for (int i = 0; i < tokens.length; i++)
    12
    for (int i = 0; i < tables.length; i++)
    Differences
    Expression1Expression2Difference
    tokenstablesVARIABLE_NAME_MISMATCH
    12
    for (int i = 0; i < tables.length; i++)
                                                      
    13
    if (tables.length > 1)
                                                                                                                        
    14
    buf.append("select ").append(column).append(" from ");
    39
    buf.append(tokens[i]);
    39
    buf.append(tokens[i]);
    15
    buf.append(Table.qualify(catalog, schema, tables[i]));
    Differences
    Expression1Expression2Difference
    tokens[i]Table.qualify(catalog,schema,tables[i])TYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression tokens[i] cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression Table.qualify(catalog,schema,tables[i]) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    15
    buf.append(Table.qualify(catalog, schema, tables[i]));
    40
    if (!isSubselect)
                                            
    41
    buf.append(" as ").append(NameGenerator.scalarName(c, i));
    41
    buf.append(" as ").append(NameGenerator.scalarName(c, i));
    Preondition Violations
    Unmatched statement buf.append(" as ").append(NameGenerator.scalarName(c,i)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                                              
    42
    if (i != tokens.length - 1)
    42
    if (i != tokens.length - 1)
    16
    if (i < tables.length - 1)
    Differences
    Expression1Expression2Difference
    tokenstablesVARIABLE_NAME_MISMATCH
    !=<OPERATOR_MISMATCH
    Preondition Violations
    Expression i != tokens.length - 1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression i < tables.length - 1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    16
    if (i < tables.length - 1)
    43
    buf.append(", ");
    43
    buf.append(", ");
    17
    buf.append(" union ");
    Differences
    Expression1Expression2Difference
    ", "" union "LITERAL_VALUE_MISMATCH
    17
    buf.append(" union ");
    Precondition Violations (7)
    Row Violation
    1Expression tokens[i] cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression Table.qualify(catalog,schema,tables[i]) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Unmatched statement buf.append(" as ").append(NameGenerator.scalarName(c,i)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4Expression i != tokens.length - 1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Expression i < tables.length - 1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Clone fragment #1 returns variables i , while Clone fragment #2 returns variables
    7The refactoring of the clones is infeasible, because classes org.hibernate.hql.classic.QueryTranslatorImpl and org.hibernate.id.IncrementGenerator do not have a common superclass