diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/Informix10Dialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/Informix10Dialect.java new file mode 100644 index 0000000000..dbf841bc56 --- /dev/null +++ b/hibernate-core/src/main/java/org/hibernate/dialect/Informix10Dialect.java @@ -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(); + } + +} diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/InformixDialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/InformixDialect.java index 5829b5c0e1..7ef27c98d9 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/InformixDialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/InformixDialect.java @@ -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;