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();
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();
Clone fragments detected by clone detection tool
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: 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
		
2
		
3
sql = sql.trim();
3
		sql = sql.trim();
4
		boolean isForUpdate = false;
4
		boolean isForUpdate = false;
5
		if ( sql.toLowerCase().endsWith(" for update") ) {
5
		if ( sql.toLowerCase().endsWith(" for update") ) {
6
			sql = sql.substring( 0, sql.length()-11 );
6
			sql = sql.substring( 0, sql.length()-11 );
7
			isForUpdate = true;
7
			isForUpdate = true;
8
		}
8
		}
9
		
9
		StringBuffer pagingSelect = new StringBuffer( sql.length()+100 );
10
		StringBuffer pagingSelect = new StringBuffer( sql.length()+100 );
10
		if (hasOffset) {
11
		if (hasOffset) {
11
			pagingSelect.append("select * from ( select row_.*, rownum rownum_ from ( ");
12
			pagingSelect.append("select * from ( select row_.*, rownum rownum_ from ( ");
12
		}
13
		}
13
		else {
14
		else {
14
			pagingSelect.append("select * from ( ");
15
			pagingSelect.append("select * from ( ");
15
		}
16
		}
16
		pagingSelect.append(sql);
17
		pagingSelect.append(sql);
17
		if (hasOffset) {
18
		if (hasOffset) {
18
			pagingSelect.append(" ) row_ ) where rownum_ <= ? and rownum_ > ?");
19
			pagingSelect.append(" ) row_ where rownum <= ?) where rownum_ > ?");
19
		}
20
		}
20
		else {
21
		else {
21
			pagingSelect.append(" ) where rownum <= ?");
22
			pagingSelect.append(" ) where rownum <= ?");
22
		}
23
		}
23
		if ( isForUpdate ) {
24
		if ( isForUpdate ) {
24
			pagingSelect.append( " for update" );
25
			pagingSelect.append( " for update" );
25
		}
26
		}
27
		
26
		return pagingSelect.toString();
28
		return pagingSelect.toString();
27
	
29
	
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