Author: dstephan
Date: 2008-09-24 01:02:10 -0400 (Wed, 24 Sep 2008)
New Revision: 15214
Modified:
core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/dialect/Dialect.java
core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/loader/Loader.java
Log:
JBPAPP-1205 - Added forceLimitUsage
Modified: core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/dialect/Dialect.java
===================================================================
--- core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/dialect/Dialect.java 2008-09-23
12:16:41 UTC (rev 15213)
+++ core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/dialect/Dialect.java 2008-09-24
05:02:10 UTC (rev 15214)
@@ -805,6 +805,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.
@@ -813,7 +823,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/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/loader/Loader.java
===================================================================
--- core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/loader/Loader.java 2008-09-23
12:16:41 UTC (rev 15213)
+++ core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/loader/Loader.java 2008-09-24
05:02:10 UTC (rev 15214)
@@ -1638,7 +1638,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 );
Show replies by date