HHH-9851 : Limit handling is broken for dialects that don't support variable limit/offset

This commit is contained in:
Gail Badner 2015-06-05 14:11:33 -07:00
parent 30b260f14f
commit d0b429dc32
7 changed files with 11 additions and 11 deletions

View File

@ -26,7 +26,7 @@ public class DB2390Dialect extends DB2Dialect {
if (LimitHelper.hasFirstRow( selection )) {
throw new UnsupportedOperationException( "query result offset is not supported" );
}
return sql + " fetch first ? rows only";
return sql + " fetch first " + getMaxOrLimit( selection ) + " rows only";
}
@Override

View File

@ -25,7 +25,7 @@ public class DB2400Dialect extends DB2Dialect {
if (LimitHelper.hasFirstRow( selection )) {
throw new UnsupportedOperationException( "query result offset is not supported" );
}
return sql + " fetch first ? rows only";
return sql + " fetch first " + getMaxOrLimit( selection ) + " rows only";
}
@Override

View File

@ -53,10 +53,10 @@ public class DB2Dialect extends Dialect {
if (LimitHelper.hasFirstRow( selection )) {
//nest the main query in an outer select
return "select * from ( select inner2_.*, rownumber() over(order by order of inner2_) as rownumber_ from ( "
+ sql + " fetch first ? rows only ) as inner2_ ) as inner1_ where rownumber_ > "
+ "? order by rownumber_";
+ sql + " fetch first " + getMaxOrLimit( selection ) + " rows only ) as inner2_ ) as inner1_ where rownumber_ > "
+ selection.getFirstRow() + " order by rownumber_";
}
return sql + " fetch first ? rows only";
return sql + " fetch first " + getMaxOrLimit( selection ) + " rows only";
}
@Override

View File

@ -285,13 +285,13 @@ public class DerbyDialect extends DB2Dialect {
}
if (LimitHelper.hasFirstRow( selection )) {
sb.append( " offset ? rows fetch next " );
sb.append( " offset " ).append( selection.getFirstRow() ).append( " rows fetch next " );
}
else {
sb.append( " fetch first " );
}
sb.append( "? rows only" );
sb.append( getMaxOrLimit( selection ) ).append(" rows only" );
if (hasForUpdateClause( forUpdateIndex )) {
sb.append( ' ' );

View File

@ -38,8 +38,8 @@ public class Ingres9Dialect extends IngresDialect {
private static final LimitHandler LIMIT_HANDLER = new AbstractLimitHandler() {
@Override
public String processSql(String sql, RowSelection selection) {
final String soff = " offset ?";
final String slim = " fetch first ? rows only";
final String soff = " offset " + selection.getFirstRow();
final String slim = " fetch first " + getMaxOrLimit( selection ) + " rows only";
final StringBuilder sb = new StringBuilder( sql.length() + soff.length() + slim.length() )
.append( sql );
if (LimitHelper.hasFirstRow( selection )) {

View File

@ -58,7 +58,7 @@ public class RDMSOS2200Dialect extends Dialect {
if (hasOffset) {
throw new UnsupportedOperationException( "query result offset is not supported" );
}
return sql + " fetch first ? rows only ";
return sql + " fetch first " + getMaxOrLimit( selection ) + " rows only ";
}
@Override

View File

@ -29,7 +29,7 @@ public class FirstLimitHandler extends AbstractLimitHandler {
}
return new StringBuilder( sql.length() + 16 )
.append( sql )
.insert( sql.toLowerCase(Locale.ROOT).indexOf( "select" ) + 6, " first ?" )
.insert( sql.toLowerCase(Locale.ROOT).indexOf( "select" ) + 6, " first " + getMaxOrLimit( selection ) )
.toString();
}