private String getErrorString() { StringBuffer buf = new StringBuffer(); for ( Iterator iterator = errorList.iterator(); iterator.hasNext(); ) { buf.append( ( String ) iterator.next() ); if ( iterator.hasNext() ) buf.append( "\n" ); } return buf.toString(); }
public String toStatementString() { if ( tableName == null ) throw new HibernateException( "no table name defined for insert-select" ); if ( select == null ) throw new HibernateException( "no select defined for insert-select" ); StringBuffer buf = new StringBuffer( (columnNames.size() * 15) + tableName.length() + 10 ); if ( comment!=null ) { buf.append( "/* " ).append( comment ).append( " */ " ); } buf.append( "insert into " ).append( tableName ); if ( !columnNames.isEmpty() ) { buf.append( " (" ); Iterator itr = columnNames.iterator(); while ( itr.hasNext() ) { buf.append( itr.next() ); if ( itr.hasNext() ) { buf.append( ", " ); } } buf.append( ")" ); } buf.append( ' ' ).append( select.toStatementString() ); return buf.toString(); }
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/hql/ast/ErrorCounter.java File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/sql/InsertSelect.java
Method name: String getErrorString() Method name: String toStatementString()
Number of AST nodes: 4 Number of AST nodes: 4
1
private String getErrorString() {
1
public String toStatementString() {
2
		StringBuffer buf = new StringBuffer();
2
		if ( tableName == null ) throw new HibernateException( "no table name defined for insert-select" );
3
		for ( Iterator iterator = errorList.iterator(); iterator.hasNext(); ) {
3
		if ( select == null ) throw new HibernateException( "no select defined for insert-select" );
4
			buf.append( ( String ) iterator.next() );
4
5
			if ( iterator.hasNext() ) buf.append( "\n" );
5
		StringBuffer buf = new StringBuffer( (columnNames.size() * 15) + tableName.length() + 10 );
6
6
		if ( comment!=null ) {
7
		}
7
			buf.append( "/* " ).append( comment ).append( " */ " );
8
		return buf.toString();
8
		}
9
	}
9
		buf.append( "insert into " ).append( tableName );
10
		if ( !columnNames.isEmpty() ) {
11
			buf.append( " (" );
12
			Iterator itr = columnNames.iterator();
13
			while ( itr.hasNext() ) {
14
				buf.append( itr.next() );
15
				if ( itr.hasNext() ) {
16
					buf.append( ", " );
17
				}
18
			}
19
			buf.append( ")" );
20
		}
21
		buf.append( ' ' ).append( select.toStatementString() );
22
		return buf.toString();
23
	}
  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)0.0
    Similarity Score0.800
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    2
    for (Iterator iterator = errorList.iterator(); iterator.hasNext(); )
    2
    for (Iterator iterator = errorList.iterator(); iterator.hasNext(); )
    12
    while (itr.hasNext())
    Differences
    Expression1Expression2Difference
    iteratoritrVARIABLE_NAME_MISMATCH
    errorListcolumnNamesVARIABLE_NAME_MISMATCH
    12
    while (itr.hasNext())
    3
    buf.append((String)iterator.next());
    3
    buf.append((String)iterator.next());
    Preondition Violations
    Unmatched statement buf.append((String)iterator.next()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                  
                                                          
    13
    buf.append(itr.next());
    4
    if (iterator.hasNext())
    4
    if (iterator.hasNext())
    14
    if (itr.hasNext())
    Differences
    Expression1Expression2Difference
    iteratoritrVARIABLE_NAME_MISMATCH
    14
    if (itr.hasNext())
    5
    buf.append("\n");
    5
    buf.append("\n");
    15
    buf.append(", ");
    Differences
    Expression1Expression2Difference
    "\n"", "LITERAL_VALUE_MISMATCH
    15
    buf.append(", ");
    Precondition Violations (2)
    Row Violation
    1Unmatched statement buf.append((String)iterator.next()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Clone fragment #1 returns variables iterator , while Clone fragment #2 returns variables