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 | } | |||
See real code fragment | See real code fragment |
Number of mapped statements | 4 |
Number of unmapped statements in the first code fragment | 1 |
Number of unmapped statements in the second code fragment | 1 |
Time elapsed for statement mapping (ms) | 0.0 |
Similarity Score | 0.800 |
Clone type | Type 2 |
ID | Statement | ID | Statement | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
2 | for (Iterator iterator = errorList.iterator(); iterator.hasNext(); ) |
| 12 | while (itr.hasNext()) | |||||||||||||
3 | buf.append((String)iterator.next()); |
| | ||||||||||||||
| 13 | buf.append(itr.next()); | |||||||||||||||
4 | if (iterator.hasNext()) |
| 14 | if (itr.hasNext()) | |||||||||||||
5 | buf.append("\n"); |
| 15 | buf.append(", "); |
Row | Violation |
---|---|
1 | 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 |
2 | Clone fragment #1 returns variables iterator , while Clone fragment #2 returns variables |