HHH-12856 Reintroduce limitation for legacy OS400

This commit is contained in:
Pierrick Rouxel 2019-01-02 23:12:58 +01:00 committed by Andrea Boriero
parent b204c95e0c
commit 1038a0c968
2 changed files with 23 additions and 0 deletions

View File

@ -31,6 +31,17 @@ public class DB2400Dialect extends DB2Dialect {
return null;
}
@Override
public String getLimitString(String sql, int offset, int limit) {
if ( offset > 0 ) {
throw new UnsupportedOperationException( "query result offset is not supported" );
}
if ( limit == 0 ) {
return sql;
}
return sql + " fetch first " + limit + " rows only ";
}
@Override
public String getForUpdateString() {
return " for update with rs";

View File

@ -44,6 +44,18 @@ public class DB2400V7R3Dialect extends DB2400Dialect {
"or sequence_schema = current_schema";
}
@Override
@SuppressWarnings("deprecation")
public String getLimitString(String sql, int offset, int limit) {
if ( offset == 0 ) {
return sql + " fetch first " + limit + " rows only";
}
//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 " + limit + " rows only ) as inner2_ ) as inner1_ where rownumber_ > "
+ offset + " order by rownumber_";
}
@Override
public IdentityColumnSupport getIdentityColumnSupport() {
return new DB2IdentityColumnSupport();