From e0694c871b9b12b8b9edb1447dbe8264628034a3 Mon Sep 17 00:00:00 2001 From: Strong Liu Date: Mon, 15 Mar 2010 12:49:58 +0000 Subject: [PATCH] HHH-4946 org.hibernate.test.legacy.FooBarTests testLimit failure with Ingres git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@18999 1b8cb986-b30d-0410-93ca-fae66ebed9b2 --- .../org/hibernate/dialect/Ingres9Dialect.java | 26 ++++++++++++++----- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/core/src/main/java/org/hibernate/dialect/Ingres9Dialect.java b/core/src/main/java/org/hibernate/dialect/Ingres9Dialect.java index 5f5e250f7a..5434a3dd7e 100644 --- a/core/src/main/java/org/hibernate/dialect/Ingres9Dialect.java +++ b/core/src/main/java/org/hibernate/dialect/Ingres9Dialect.java @@ -3,6 +3,7 @@ package org.hibernate.dialect; import java.sql.Types; import org.hibernate.Hibernate; +import org.hibernate.cfg.Environment; import org.hibernate.dialect.function.NoArgSQLFunction; /** @@ -41,7 +42,6 @@ public class Ingres9Dialect extends IngresDialect { */ protected void registerDateTimeColumnTypes() { registerColumnType(Types.DATE, "ansidate"); - //registerColumnType(Types.TIME, "time with time zone"); registerColumnType(Types.TIMESTAMP, "timestamp(9) with time zone"); } @@ -126,7 +126,7 @@ public class Ingres9Dialect extends IngresDialect { } /** - * Retrieve the command used to retrieve the current timestamp from the + * Retrieve the command used to retrieve the current timestammp from the * database. * * @return The command. @@ -189,7 +189,7 @@ public class Ingres9Dialect extends IngresDialect { } /** - * Does this dialect support bind variables (i.e., prepared statement + * Does this dialect support bind variables (i.e., prepared statememnt * parameters) for its limit/offset? * * @return false @@ -198,18 +198,30 @@ public class Ingres9Dialect extends IngresDialect { return false; } + /** + * Does the LIMIT clause take a "maximum" row number instead + * of a total number of returned rows? + */ + public boolean useMaxForLimit() { + return false; + } + /** * Add a LIMIT clause to the given SQL SELECT * * @return the modified SQL */ public String getLimitString(String querySelect, int offset, int limit) { - StringBuffer sb = new StringBuffer(querySelect.length() + 16); - sb.append(querySelect.trim()).insert(6, " first " + limit); + StringBuffer soff = new StringBuffer(" offset " + offset); + StringBuffer slim = new StringBuffer(" fetch first " + limit + " rows only"); + StringBuffer sb = new StringBuffer(querySelect.length() + + soff.length() + slim.length()).append(querySelect); if (offset > 0) { - sb.append(" offset " + offset); + sb.append(soff); } + if (limit > 0) { + sb.append(slim); + } return sb.toString(); } - }