HHH-11509 - Infomix limit handler support for offset

This commit is contained in:
marcgiffing 2017-03-02 21:47:11 +01:00 committed by Chris Cranford
parent 05a13b8b27
commit 51d9bbfc7c
2 changed files with 32 additions and 6 deletions

View File

@ -0,0 +1,16 @@
package org.hibernate.dialect;
import org.hibernate.dialect.pagination.InformixLimitHandler;
import org.hibernate.dialect.pagination.LimitHandler;
/**
* Since version 10.00.xC3 Informix has limit/offset support which was introduced in July 2005.
*/
public class Informix10Dialect extends InformixDialect {
@Override
public LimitHandler getLimitHandler() {
return new InformixLimitHandler();
}
}

View File

@ -16,15 +16,11 @@ import org.hibernate.dialect.function.SQLFunctionTemplate;
import org.hibernate.dialect.function.VarArgsSQLFunction;
import org.hibernate.dialect.identity.IdentityColumnSupport;
import org.hibernate.dialect.identity.InformixIdentityColumnSupport;
import org.hibernate.dialect.pagination.AbstractLimitHandler;
import org.hibernate.dialect.pagination.FirstLimitHandler;
import org.hibernate.dialect.pagination.InformixLimitHandler;
import org.hibernate.dialect.pagination.LegacyFirstLimitHandler;
import org.hibernate.dialect.pagination.LimitHandler;
import org.hibernate.dialect.pagination.LimitHelper;
import org.hibernate.dialect.unique.InformixUniqueDelegate;
import org.hibernate.dialect.unique.UniqueDelegate;
import org.hibernate.engine.spi.RowSelection;
import org.hibernate.exception.spi.TemplatedViolatedConstraintNameExtracter;
import org.hibernate.exception.spi.ViolatedConstraintNameExtracter;
import org.hibernate.hql.spi.id.IdTableSupportStandardImpl;
@ -183,9 +179,12 @@ public class InformixDialect extends Dialect {
@Override
public LimitHandler getLimitHandler() {
return new InformixLimitHandler();
if ( isLegacyLimitHandlerBehaviorEnabled() ) {
return LegacyFirstLimitHandler.INSTANCE;
}
return FirstLimitHandler.INSTANCE;
}
@Override
public boolean supportsLimit() {
return true;
@ -201,6 +200,17 @@ public class InformixDialect extends Dialect {
return false;
}
@Override
public String getLimitString(String querySelect, int offset, int limit) {
if ( offset > 0 ) {
throw new UnsupportedOperationException( "query result offset is not supported" );
}
return new StringBuilder( querySelect.length() + 8 )
.append( querySelect )
.insert( querySelect.toLowerCase(Locale.ROOT).indexOf( "select" ) + 6, " first " + limit )
.toString();
}
@Override
public boolean supportsVariableLimit() {
return false;