File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/dialect/Oracle8iDialect.java | File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/dialect/Oracle9Dialect.java | |||
Method name: String getLimitString(String, boolean)
|
Method name: String getLimitString(String, boolean)
|
|||
Number of AST nodes: 16 | Number of AST nodes: 16 | |||
1 | sql = sql.trim();↵ | 1 | sql = sql.trim();↵ | |
2 | boolean isForUpdate = false;↵ | 2 | boolean isForUpdate = false;↵ | |
3 | if ( sql.toLowerCase().endsWith(" for update") ) {↵ | 3 | if ( sql.toLowerCase().endsWith(" for update") ) {↵ | |
4 | sql = sql.substring( 0, sql.length()-11 );↵ | 4 | sql = sql.substring( 0, sql.length()-11 );↵ | |
5 | isForUpdate = true;↵ | 5 | isForUpdate = true;↵ | |
6 | }↵ | 6 | }↵ | |
7 | ↵ | |||
7 | StringBuffer pagingSelect = new StringBuffer( sql.length()+100 );↵ | 8 | StringBuffer pagingSelect = new StringBuffer( sql.length()+100 );↵ | |
8 | if (hasOffset) {↵ | 9 | if (hasOffset) {↵ | |
9 | pagingSelect.append("select * from ( select row_.*, rownum rownum_ from ( ");↵ | 10 | pagingSelect.append("select * from ( select row_.*, rownum rownum_ from ( ");↵ | |
10 | }↵ | 11 | }↵ | |
11 | else {↵ | 12 | else {↵ | |
12 | pagingSelect.append("select * from ( ");↵ | 13 | pagingSelect.append("select * from ( ");↵ | |
13 | }↵ | 14 | }↵ | |
14 | pagingSelect.append(sql);↵ | 15 | pagingSelect.append(sql);↵ | |
15 | if (hasOffset) {↵ | 16 | if (hasOffset) {↵ | |
16 | pagingSelect.append(" ) row_ ) where rownum_ <= ? and rownum_ > ?");↵ | 17 | pagingSelect.append(" ) row_ where rownum <= ?) where rownum_ > ?");↵ | |
17 | }↵ | 18 | }↵ | |
18 | else {↵ | 19 | else {↵ | |
19 | pagingSelect.append(" ) where rownum <= ?");↵ | 20 | pagingSelect.append(" ) where rownum <= ?");↵ | |
20 | }↵ | 21 | }↵ | |
21 | if ( isForUpdate ) {↵ | 22 | if ( isForUpdate ) {↵ | |
22 | pagingSelect.append( " for update" );↵ | 23 | pagingSelect.append( " for update" );↵ | |
23 | }↵ | 24 | }↵ | |
25 | ↵ | |||
24 | return pagingSelect.toString(); | 26 |
| |
See real code fragment | See real code fragment |
Number of common nesting structure subtrees | 1 |
Number of refactorable cases | 1 |
Number of non-refactorable cases | 0 |
Time elapsed for finding largest common nesting structure subtrees (ms) | 0.9 |
Clones location | Clones are in different classes having the same super class |
Number of node comparisons | 99 |
Number of mapped statements | 16 |
Number of unmapped statements in the first code fragment | 0 |
Number of unmapped statements in the second code fragment | 0 |
Time elapsed for statement mapping (ms) | 5.9 |
Clone type | Type 2 |
ID | Statement | ID | Statement | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | sql = sql.trim(); | 1 | sql = sql.trim(); | |||||||||||
2 | boolean isForUpdate = false; | 2 | boolean isForUpdate = false; | |||||||||||
3 | if (sql.toLowerCase().endsWith(" for update")) | 3 | if (sql.toLowerCase().endsWith(" for update")) | |||||||||||
4 | sql = sql.substring(0, sql.length() - 11); | 4 | sql = sql.substring(0, sql.length() - 11); | |||||||||||
5 | isForUpdate = true; | 5 | isForUpdate = true; | |||||||||||
6 | StringBuffer pagingSelect = new StringBuffer(sql.length() + 100); | 6 | StringBuffer pagingSelect = new StringBuffer(sql.length() + 100); | |||||||||||
7 | if (hasOffset) | 7 | if (hasOffset) | |||||||||||
8 | pagingSelect.append("select * from ( select row_.*, rownum rownum_ from ( "); | 8 | pagingSelect.append("select * from ( select row_.*, rownum rownum_ from ( "); | |||||||||||
else | else | |||||||||||||
9 | pagingSelect.append("select * from ( "); | 9 | pagingSelect.append("select * from ( "); | |||||||||||
10 | pagingSelect.append(sql); | 10 | pagingSelect.append(sql); | |||||||||||
11 | if (hasOffset) | 11 | if (hasOffset) | |||||||||||
12 | pagingSelect.append(" ) row_ ) where rownum_ <= ? and rownum_ > ?"); |
| 12 | pagingSelect.append(" ) row_ where rownum <= ?) where rownum_ > ?"); | ||||||||||
else | else | |||||||||||||
13 | pagingSelect.append(" ) where rownum <= ?"); | 13 | pagingSelect.append(" ) where rownum <= ?"); | |||||||||||
14 | if (isForUpdate) | 14 | if (isForUpdate) | |||||||||||
15 | pagingSelect.append(" for update"); | 15 | pagingSelect.append(" for update"); | |||||||||||
16 | return pagingSelect.toString(); | 16 | return pagingSelect.toString(); |
Row | Violation |
---|