[hibernate-commits] Hibernate SVN: r15192 - in core/trunk/core/src/main/java/org/hibernate: loader and 1 other directory.

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Fri Sep 12 02:17:00 EDT 2008


Author: steve.ebersole at jboss.com
Date: 2008-09-12 02:17:00 -0400 (Fri, 12 Sep 2008)
New Revision: 15192

Modified:
   core/trunk/core/src/main/java/org/hibernate/dialect/Dialect.java
   core/trunk/core/src/main/java/org/hibernate/loader/Loader.java
Log:
HHH-2592 : Dialect.forceLimitUsage

Modified: core/trunk/core/src/main/java/org/hibernate/dialect/Dialect.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/dialect/Dialect.java	2008-09-12 06:16:31 UTC (rev 15191)
+++ core/trunk/core/src/main/java/org/hibernate/dialect/Dialect.java	2008-09-12 06:17:00 UTC (rev 15192)
@@ -768,16 +768,6 @@
 	}
 
 	/**
-	 * Generally, if there is no limit applied to a Hibernate query we do not apply any limits
-	 * to the SQL query.  This option forces that the limit be written to the SQL query.
-	 *
-	 * @return True to force limit into SQL query even if none specified in Hibernate query; false otherwise.
-	 */
-	public boolean forceLimitUsage() {
-		return true;
-	}
-
-	/**
 	 * Does this dialect's LIMIT support (if any) additionally
 	 * support specifying an offset?
 	 *
@@ -838,6 +828,16 @@
 	}
 
 	/**
+	 * Generally, if there is no limit applied to a Hibernate query we do not apply any limits
+	 * to the SQL query.  This option forces that the limit be written to the SQL query.
+	 *
+	 * @return True to force limit into SQL query even if none specified in Hibernate query; false otherwise.
+	 */
+	public boolean forceLimitUsage() {
+		return false;
+	}
+
+	/**
 	 * Given a limit and an offset, apply the limit clause to the query.
 	 *
 	 * @param query The query to which to apply the limit.
@@ -846,7 +846,7 @@
 	 * @return The modified query statement with the limit applied.
 	 */
 	public String getLimitString(String query, int offset, int limit) {
-		return getLimitString( query, offset > 0 );
+		return getLimitString( query, ( offset > 0 || forceLimitUsage() )  );
 	}
 
 	/**

Modified: core/trunk/core/src/main/java/org/hibernate/loader/Loader.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/loader/Loader.java	2008-09-12 06:16:31 UTC (rev 15191)
+++ core/trunk/core/src/main/java/org/hibernate/loader/Loader.java	2008-09-12 06:17:00 UTC (rev 15192)
@@ -1526,7 +1526,7 @@
 	 * LIMIT clause.
 	 */
 	private static boolean useLimit(final RowSelection selection, final Dialect dialect) {
-		return dialect.supportsLimit() && ( hasMaxRows( selection ) || dialect.forceLimitUsage() );
+		return dialect.supportsLimit() && hasMaxRows( selection );
 	}
 
 	/**
@@ -1659,7 +1659,7 @@
 		}
 		int firstRow = getFirstRow( selection );
 		int lastRow = getMaxOrLimit( selection, dialect );
-		boolean hasFirstRow = firstRow > 0 && dialect.supportsLimitOffset();
+		boolean hasFirstRow = dialect.supportsLimitOffset() && ( firstRow > 0 || dialect.forceLimitUsage() );
 		boolean reverse = dialect.bindLimitParametersInReverseOrder();
 		if ( hasFirstRow ) {
 			statement.setInt( index + ( reverse ? 1 : 0 ), firstRow );




More information about the hibernate-commits mailing list