File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/id/TableGenerator.java | File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/id/enhanced/TableStructure.java | |||
Method name: Serializable doWorkInCurrentTransaction(Connection, String)
|
Method name: Serializable doWorkInCurrentTransaction(Connection, String)
|
|||
Number of AST nodes: 18 | Number of AST nodes: 17 | |||
1 | sql = query;↵ | |||
2 | SQL_STATEMENT_LOGGER.logStatement( sql, FormatStyle.BASIC );↵ | 1 | SQL_STATEMENT_LOGGER.logStatement( selectQuery, FormatStyle.BASIC ); ↵ | |
3 | PreparedStatement qps = conn.prepareStatement(query);↵ | 2 | PreparedStatement selectPS = conn.prepareStatement( selectQuery ); ↵ | |
4 | try {↵ | 3 | try { ↵ | |
5 | ResultSet rs = qps.executeQuery();↵ | 4 | ResultSet selectRS = selectPS.executeQuery(); ↵ | |
6 | if ( !rs.next() ) {↵ | 5 | if ( !selectRS.next() ) { ↵ | |
7 | String err = "could not read a hi value - you need to populate the table: " + tableName;↵ | 6 | String err = "could not read a hi value - you need to populate the table: " + tableName; ↵ | |
8 | log.error(err);↵ | 7 | log.error( err ); ↵ | |
9 | throw new IdentifierGenerationException(err);↵ | 8 | throw new IdentifierGenerationException( err ); ↵ | |
10 | }↵ | 9 | } ↵ | |
11 | result = rs.getInt(1);↵ | 10 | result = selectRS.getLong( 1 ); ↵ | |
12 | rs.close();↵ | 11 | selectRS.close(); ↵ | |
13 | }↵ | 12 | } ↵ | |
14 | catch (SQLException sqle) {↵ | 13 | catch ( SQLException sqle ) { ↵ | |
15 | log.error("could not read a hi value", sqle);↵ | 14 | log.error( "could not read a hi value", sqle ); ↵ | |
16 | throw sqle;↵ | 15 | throw sqle; ↵ | |
17 | }↵ | 16 | } ↵ | |
18 | finally {↵ | 17 | finally { ↵ | |
19 | qps.close();↵ | 18 | selectPS.close(); ↵ | |
20 | }↵ | 19 | }↵ | |
21 | sql = update;↵ | |||
20 | ↵ | |||
22 | SQL_STATEMENT_LOGGER.logStatement( sql, FormatStyle.BASIC );↵ | 21 | SQL_STATEMENT_LOGGER.logStatement( updateQuery, FormatStyle.BASIC ); ↵ | |
23 | PreparedStatement ups = conn.prepareStatement(update);↵ | 22 | PreparedStatement updatePS = conn.prepareStatement( updateQuery ); ↵ | |
24 | try {↵ | 23 | try { ↵ | |
25 | ups.setInt↵ | 24 | int increment = applyIncrementSizeToSourceValues ? incrementSize : 1;↵ | |
26 | ( 1, result + 1 );↵ | 25 | updatePS.setLong( 1, result + increment ); ↵ | |
27 | ups.setInt( 2, result );↵ | 26 | updatePS.setLong( 2, result ); ↵ | |
28 | rows = ups.executeUpdate();↵ | 27 | rows = updatePS.executeUpdate(); ↵ | |
29 | }↵ | 28 | } ↵ | |
30 | catch (SQLException sqle) {↵ | 29 | catch ( SQLException sqle ) { ↵ | |
31 | log.error("could not update hi value in: " + tableName, sqle);↵ | 30 | log.error( "could not updateQuery hi value in: " + tableName, sqle ); ↵ | |
32 | throw sqle;↵ | 31 | throw sqle; ↵ | |
33 | }↵ | 32 | } ↵ | |
34 | finally {↵ | 33 | finally { ↵ | |
35 | ups.close();↵ | 34 | updatePS.close(); ↵ | |
36 | } | 35 |
| |
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.7 |
Clones location | Clones are in different classes having the same super class |
Number of node comparisons | 77 |
Number of mapped statements | 13 |
Number of unmapped statements in the first code fragment | 5 |
Number of unmapped statements in the second code fragment | 4 |
Time elapsed for statement mapping (ms) | 8.8 |
Clone type | Type 3 |
ID | Statement | ID | Statement | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
3 | sql = query; |
| | ||||||||||||||
4 | SQL_STATEMENT_LOGGER.logStatement(sql, FormatStyle.BASIC); |
| 3 | SQL_STATEMENT_LOGGER.logStatement(selectQuery, FormatStyle.BASIC); | |||||||||||||
5 | PreparedStatement qps = conn.prepareStatement(query); |
| 4 | PreparedStatement selectPS = conn.prepareStatement(selectQuery); | |||||||||||||
6 | try |
| 5 | try | |||||||||||||
7 | ResultSet rs = qps.executeQuery(); |
| 6 | ResultSet selectRS = selectPS.executeQuery(); | |||||||||||||
8 | if (!rs.next()) |
| 7 | if (!selectRS.next()) | |||||||||||||
9 | String err = "could not read a hi value - you need to populate the table: " + tableName; | 8 | String err = "could not read a hi value - you need to populate the table: " + tableName; | ||||||||||||||
10 | log.error(err); | 9 | log.error(err); | ||||||||||||||
11 | throw new IdentifierGenerationException(err); | 10 | throw new IdentifierGenerationException(err); | ||||||||||||||
|
| 11 | result = selectRS.getLong(1); | ||||||||||||||
12 | result = rs.getInt(1); |
| | ||||||||||||||
13 | rs.close(); |
| 12 | selectRS.close(); | |||||||||||||
14 | sql = update; |
| | ||||||||||||||
15 | SQL_STATEMENT_LOGGER.logStatement(sql, FormatStyle.BASIC); |
| 13 | SQL_STATEMENT_LOGGER.logStatement(updateQuery, FormatStyle.BASIC); | |||||||||||||
16 | PreparedStatement ups = conn.prepareStatement(update); |
| 14 | PreparedStatement updatePS = conn.prepareStatement(updateQuery); | |||||||||||||
17 | try |
| 15 | try | |||||||||||||
| 16 | int increment = applyIncrementSizeToSourceValues ? incrementSize : 1; | |||||||||||||||
|
| 17 | updatePS.setLong(1, result + increment); | ||||||||||||||
|
| 18 | updatePS.setLong(2, result); | ||||||||||||||
18 | ups.setInt(1, result + 1); |
| | ||||||||||||||
19 | ups.setInt(2, result); |
| | ||||||||||||||
20 | rows = ups.executeUpdate(); |
| 19 | rows = updatePS.executeUpdate(); |
Row | Violation |
---|---|
1 | Unmatched statement sql=query; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
2 | Expression sql cannot be parameterized, because it has dependencies to/from statements that will be extracted |
3 | Unmatched statement result=selectRS.getLong(1); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
4 | Unmatched statement result=selectRS.getLong(1); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted |
5 | Unmatched statement result=rs.getInt(1); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
6 | Unmatched statement result=rs.getInt(1); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted |
7 | Unmatched statement sql=update; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
8 | Expression sql cannot be parameterized, because it has dependencies to/from statements that will be extracted |
9 | Unmatched statement updatePS.setLong(1,result + increment); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
10 | Unmatched statement updatePS.setLong(1,result + increment); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted |
11 | Unmatched statement updatePS.setLong(2,result); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
12 | Unmatched statement updatePS.setLong(2,result); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted |
13 | Unmatched statement ups.setInt(1,result + 1); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
14 | Unmatched statement ups.setInt(1,result + 1); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted |
15 | Unmatched statement ups.setInt(2,result); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
16 | Unmatched statement ups.setInt(2,result); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted |
17 | Clone fragment #1 returns variables rs, ups, rows , while Clone fragment #2 returns variables selectRS, updatePS, rows |