HHH-2592 : Dialect.forceLimitUsage
git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@15192 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
parent
f85f5cc0c8
commit
664029469b
|
@ -767,16 +767,6 @@ public abstract class Dialect {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 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
|
* Does this dialect's LIMIT support (if any) additionally
|
||||||
* support specifying an offset?
|
* support specifying an offset?
|
||||||
|
@ -837,6 +827,16 @@ public abstract class Dialect {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
* Given a limit and an offset, apply the limit clause to the query.
|
||||||
*
|
*
|
||||||
|
@ -846,7 +846,7 @@ public abstract class Dialect {
|
||||||
* @return The modified query statement with the limit applied.
|
* @return The modified query statement with the limit applied.
|
||||||
*/
|
*/
|
||||||
public String getLimitString(String query, int offset, int limit) {
|
public String getLimitString(String query, int offset, int limit) {
|
||||||
return getLimitString( query, offset > 0 );
|
return getLimitString( query, ( offset > 0 || forceLimitUsage() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1526,7 +1526,7 @@ public abstract class Loader {
|
||||||
* LIMIT clause.
|
* LIMIT clause.
|
||||||
*/
|
*/
|
||||||
private static boolean useLimit(final RowSelection selection, final Dialect dialect) {
|
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 @@ public abstract class Loader {
|
||||||
}
|
}
|
||||||
int firstRow = getFirstRow( selection );
|
int firstRow = getFirstRow( selection );
|
||||||
int lastRow = getMaxOrLimit( selection, dialect );
|
int lastRow = getMaxOrLimit( selection, dialect );
|
||||||
boolean hasFirstRow = firstRow > 0 && dialect.supportsLimitOffset();
|
boolean hasFirstRow = dialect.supportsLimitOffset() && ( firstRow > 0 || dialect.forceLimitUsage() );
|
||||||
boolean reverse = dialect.bindLimitParametersInReverseOrder();
|
boolean reverse = dialect.bindLimitParametersInReverseOrder();
|
||||||
if ( hasFirstRow ) {
|
if ( hasFirstRow ) {
|
||||||
statement.setInt( index + ( reverse ? 1 : 0 ), firstRow );
|
statement.setInt( index + ( reverse ? 1 : 0 ), firstRow );
|
||||||
|
|
Loading…
Reference in New Issue