sql = sql.trim(); boolean isForUpdate = false; if ( sql.toLowerCase().endsWith(" for update") ) { sql = sql.substring( 0, sql.length()-11 ); isForUpdate = true; } StringBuffer pagingSelect = new StringBuffer( sql.length()+100 ); if (hasOffset) { pagingSelect.append("select * from ( select row_.*, rownum rownum_ from ( "); } else { pagingSelect.append("select * from ( "); } pagingSelect.append(sql); if (hasOffset) { pagingSelect.append(" ) row_ where rownum <= ?) where rownum_ > ?"); } else { pagingSelect.append(" ) where rownum <= ?"); } if ( isForUpdate ) { pagingSelect.append( " for update" ); } return pagingSelect.toString();
sql = sql.trim(); boolean isForUpdate = false; if ( sql.toLowerCase().endsWith(" for update") ) { sql = sql.substring( 0, sql.length()-11 ); isForUpdate = true; } StringBuffer pagingSelect = new StringBuffer( sql.length()+100 ); if (hasOffset) { pagingSelect.append("select * from ( select row_.*, rownum rownum_ from ( "); } else { pagingSelect.append("select * from ( "); } pagingSelect.append(sql); if (hasOffset) { pagingSelect.append(" ) row_ ) where rownum_ <= ? and rownum_ > ?"); } else { pagingSelect.append(" ) where rownum <= ?"); } if ( isForUpdate ) { pagingSelect.append( " for update" ); } return pagingSelect.toString();
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/dialect/Oracle9iDialect.java File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/dialect/OracleDialect.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 <= ?) where rownum_ > ?");
17
			pagingSelect.append(" ) row_ ) where rownum_ <= ? and 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
		return pagingSelect.toString();
Summary
Number of common nesting structure subtrees1
Number of refactorable cases1
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)0.9
Clones locationClones are in different classes having the same super class
Number of node comparisons99
  1. {Refactorable}
    Mapping Summary
    Number of mapped statements16
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)5.7
    Clone typeType 2
    Mapped Statements
    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 <= ?) where rownum_ > ?");
    12
    pagingSelect.append(" ) row_ where rownum <= ?) where rownum_ > ?");
    12
    pagingSelect.append(" ) row_ ) where rownum_ <= ? and rownum_ > ?");
    Differences
    Expression1Expression2Difference
    " ) row_ where rownum <= ?) where rownum_ > ?"" ) row_ ) where rownum_ <= ? and rownum_ > ?"LITERAL_VALUE_MISMATCH
    12
    pagingSelect.append(" ) row_ ) where rownum_ <= ? and 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();
    Precondition Violations (0)
    Row Violation