File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/hql/ast/exec/MultiTableDeleteExecutor.java | File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/hql/ast/exec/MultiTableUpdateExecutor.java | |||
Method name: int execute(QueryParameters, SessionImplementor)
|
Method name: int execute(QueryParameters, SessionImplementor)
|
|||
Number of AST nodes: 9 | Number of AST nodes: 8 | |||
1 | try {↵ | 1 | try {↵ | |
2 | try {↵ | 2 | try {↵ | |
3 | ps = session.getBatcher().prepareStatement( idInsertSelect );↵ | 3 | ps = session.getBatcher().prepareStatement( idInsertSelect );↵ | |
4 | Iterator paramSpecification↵ | 4 | // int parameterStart = getWalker().getNumberOfParametersInSetClause();↵ | |
5 | // List allParams = getIdSelectParameterSpecifications();↵ | |||
6 | // Iterator whereParams = allParams.subList( parameterStart, allParams.size() ).iterator();↵ | |||
5 | s = getIdSelectParameterSpecifications().iterator();↵ | 7 | Iterator whereParams = getIdSelectParameterSpecifications().iterator();↵ | |
6 | int pos = 1;↵ | 8 | int sum = 1;↵ | |
7 | while ( paramSpecifications.hasNext() ) {↵ | |||
8 | final ParameterSpecification paramSpec = ( ParameterSpecification ) paramSpecifications.next();↵ | |||
9 | pos += paramSpec↵ | 9 | // jdbc params are 1-based↵ | |
10 | while ( whereParams.hasNext() ) {↵ | |||
10 | .bind( ps, parameters, session, pos );↵ | 11 | sum += ( ( ParameterSpecification ) whereParams.next() ).bind( ps, parameters, session, sum );↵ | |
11 | }↵ | 12 | }↵ | |
12 | resultCount = ps.executeUpdate();↵ | 13 | resultCount = ps.executeUpdate();↵ | |
13 | }↵ | 14 | }↵ | |
14 | finally {↵ | 15 | finally {↵ | |
15 | if ( ps != null ) {↵ | 16 | if ( ps != null ) {↵ | |
16 | session.getBatcher().closeStatement( ps );↵ | 17 | session.getBatcher().closeStatement( ps );↵ | |
17 | }↵ | 18 | }↵ | |
18 | }↵ | 19 | }↵ | |
19 | }↵ | 20 | }↵ | |
20 | catch( SQLException e ) {↵ | 21 | catch( SQLException e ) {↵ | |
21 | throw JDBCExceptionHelper.convert(↵ | 22 | throw JDBCExceptionHelper.convert(↵ | |
22 | getFactory().getSQLExceptionConverter(),↵ | 23 | getFactory().getSQLExceptionConverter(),↵ | |
23 | e,↵ | 24 | e,↵ | |
24 | "could not insert/select ids for bulk delete",↵ | 25 | "could not insert/select ids for bulk update",↵ | |
25 | idInsertSelect↵ | 26 | idInsertSelect↵ | |
26 | );↵ | 27 | );↵ | |
27 | } | 28 |
| |
See real code fragment | See real code fragment |
Number of common nesting structure subtrees | 1 |
Number of refactorable cases | 0 |
Number of non-refactorable cases | 1 |
Time elapsed for finding largest common nesting structure subtrees (ms) | 0.6 |
Clones location | Clones are in different classes having the same super class |
Number of node comparisons | 33 |
Number of mapped statements | 8 |
Number of unmapped statements in the first code fragment | 1 |
Number of unmapped statements in the second code fragment | 0 |
Time elapsed for statement mapping (ms) | 1.8 |
Clone type | Type 3 |
ID | Statement | ID | Statement | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
6 | try |
| 6 | try | |||||||||||||||||
7 | try | 7 | try | ||||||||||||||||||
8 | ps = session.getBatcher().prepareStatement(idInsertSelect); | 8 | ps = session.getBatcher().prepareStatement(idInsertSelect); | ||||||||||||||||||
9 | Iterator paramSpecifications = getIdSelectParameterSpecifications().iterator(); |
| 9 | Iterator whereParams = getIdSelectParameterSpecifications().iterator(); | |||||||||||||||||
10 | int pos = 1; |
| 10 | int sum = 1; | |||||||||||||||||
11 | while (paramSpecifications.hasNext()) |
| 11 | while (whereParams.hasNext()) | |||||||||||||||||
12 | final ParameterSpecification paramSpec = (ParameterSpecification)paramSpecifications.next(); |
| | ||||||||||||||||||
13 | pos += paramSpec.bind(ps, parameters, session, pos); |
| 12 | sum += ((ParameterSpecification)whereParams.next()).bind(ps, parameters, session, sum); | |||||||||||||||||
14 | resultCount = ps.executeUpdate(); | 13 | resultCount = ps.executeUpdate(); |
Row | Violation |
---|---|
1 | Unmatched statement final ParameterSpecification paramSpec=(ParameterSpecification)paramSpecifications.next(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
2 | Expression ((ParameterSpecification)whereParams.next()) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
3 | Clone fragment #1 returns variables paramSpecifications, resultCount , while Clone fragment #2 returns variables resultCount |