File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/sql/Insert.java | File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/hql/ast/ErrorCounter.java | |||
Method name: String toStatementString()
|
Method name: String getErrorString()
|
|||
Number of AST nodes: 4 | Number of AST nodes: 4 | |||
1 | public String toStatementString() { | 1 | private String getErrorString() { | |
2 | StringBuffer buf = new StringBuffer( columns.size()*15 + tableName.length() + 10 ); | 2 | StringBuffer buf = new StringBuffer(); | |
3 | if ( comment != null ) { | 3 | for ( Iterator iterator = errorList.iterator(); iterator.hasNext(); ) { | |
4 | buf.append( "/* " ).append( comment ).append( " */ " ); | 4 | buf.append( ( String ) iterator.next() ); | |
5 | } | 5 | if ( iterator.hasNext() ) buf.append( "\n" ); | |
6 | buf.append("insert into ") | 6 | ||
7 | .append(tableName); | 7 | } | |
8 | if ( columns.size()==0 ) { | 8 | return buf.toString(); | |
9 | buf.append(' ').append( dialect.getNoColumnsInsertString() ); | 9 | } | |
10 | } | |||
11 | else { | |||
12 | buf.append(" ("); | |||
13 | Iterator iter = columns.keySet().iterator(); | |||
14 | while ( iter.hasNext() ) { | |||
15 | buf.append( iter.next() ); | |||
16 | if ( iter.hasNext() ) { | |||
17 | buf.append( ", " ); | |||
18 | } | |||
19 | } | |||
20 | buf.append(") values ("); | |||
21 | iter = columns.values().iterator(); | |||
22 | while ( iter.hasNext() ) { | |||
23 | buf.append( iter.next() ); | |||
24 | if ( iter.hasNext() ) { | |||
25 | buf.append( ", " ); | |||
26 | } | |||
27 | } | |||
28 | buf.append(')'); | |||
29 | } | |||
30 | return buf.toString(); | |||
31 | } | |||
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 | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
15 | while (iter.hasNext()) |
| 2 | for (Iterator iterator = errorList.iterator(); iterator.hasNext(); ) | ||||||||||||||
|
| 3 | buf.append((String)iterator.next()); | |||||||||||||||
16 | buf.append(iter.next()); | | ||||||||||||||||
17 | if (iter.hasNext()) |
| 4 | if (iterator.hasNext()) | ||||||||||||||
18 | buf.append(", "); |
| 5 | buf.append("\n"); |
Row | Violation |
---|---|
1 | Type java.util.Collection of variable columns.values() does not match with type java.util.List of variable errorList |
2 | 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 |
3 | Clone fragment #1 returns variables , while Clone fragment #2 returns variables iterator |