public String getLimitString(String sql, boolean hasOffset) { 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();
public String getLimitString(String sql, boolean hasOffset) { 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/Oracle9Dialect.java File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/dialect/OracleDialect.java
Method name: Method name:
Number of AST nodes: 0 Number of AST nodes: 0
1
public String getLimitString(String sql, boolean hasOffset) {
1
public String getLimitString(String sql, boolean hasOffset) {
2
		
3
		sql = sql.trim();
2
		sql = sql.trim();
4
		boolean isForUpdate = false;
3
		boolean isForUpdate = false;
5
		if ( sql.toLowerCase().endsWith(" for update") ) {
4
		if ( sql.toLowerCase().endsWith(" for update") ) {
6
			sql = sql.substring( 0, sql.length()-11 );
5
			sql = sql.substring( 0, sql.length()-11 );
7
			isForUpdate = true;
6
			isForUpdate = true;
8
		}
7
		}
9
		
8
		
10
		StringBuffer pagingSelect = new StringBuffer( sql.length()+100 );
9
		StringBuffer pagingSelect = new StringBuffer( sql.length()+100 );
11
		if (hasOffset) {
10
		if (hasOffset) {
12
			pagingSelect.append("select * from ( select row_.*, rownum rownum_ from ( ");
11
			pagingSelect.append("select * from ( select row_.*, rownum rownum_ from ( ");
13
		}
12
		}
14
		else {
13
		else {
15
			pagingSelect.append("select * from ( ");
14
			pagingSelect.append("select * from ( ");
16
		}
15
		}
17
		pagingSelect.append(sql);
16
		pagingSelect.append(sql);
18
		if (hasOffset) {
17
		if (hasOffset) {
19
			pagingSelect.append(" ) row_ where rownum <= ?) where rownum_ > ?");
18
			pagingSelect.append(" ) row_ ) where rownum_ <= ? and rownum_ > ?");
20
		}
19
		}
21
		else {
20
		else {
22
			pagingSelect.append(" ) where rownum <= ?");
21
			pagingSelect.append(" ) where rownum <= ?");
23
		}
22
		}
24
		if ( isForUpdate ) {
23
		if ( isForUpdate ) {
25
			pagingSelect.append( " for update" );
24
			pagingSelect.append( " for update" );
26
		}
25
		}
27
		
26
		
28
		return pagingSelect.toString();
27
		return pagingSelect.toString();
29
	
28
	
Summary
Number of common nesting structure subtrees0
Number of refactorable cases0
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)0.0
Clones location
Number of node comparisons0