public abstract class AbstractLimitHandler extends Object implements LimitHandler
LimitHandler
interface.Modifier and Type | Field and Description |
---|---|
protected RowSelection |
selection |
protected String |
sql |
Constructor and Description |
---|
AbstractLimitHandler(String sql,
RowSelection selection)
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
protected int |
bindLimitParameters(PreparedStatement statement,
int index)
Default implementation of binding parameter values needed by the LIMIT clause.
|
int |
bindLimitParametersAtEndOfQuery(PreparedStatement statement,
int index)
Bind parameter values needed by the LIMIT clause after original SELECT statement.
|
int |
bindLimitParametersAtStartOfQuery(PreparedStatement statement,
int index)
Bind parameter values needed by the LIMIT clause before original SELECT statement.
|
boolean |
bindLimitParametersFirst()
Does the LIMIT clause come at the start of the
SELECT statement, rather than at the end?
|
boolean |
bindLimitParametersInReverseOrder()
ANSI SQL defines the LIMIT clause to be in the form LIMIT offset, limit.
|
int |
convertToFirstRowValue(int zeroBasedFirstResult)
Hibernate APIs explicitly state that setFirstResult() should be a zero-based offset.
|
boolean |
forceLimitUsage()
Generally, if there is no limit applied to a Hibernate query we do not apply any limits
to the SQL query.
|
protected int |
getMaxOrLimit()
Some dialect-specific LIMIT clauses require the maximum last row number
(aka, first_row_number + total_row_count), while others require the maximum
returned row count (the total maximum number of rows to return).
|
String |
getProcessedSql()
Return processed SQL query.
|
void |
setMaxRows(PreparedStatement statement)
Use JDBC API to limit the number of rows returned by the SQL query.
|
boolean |
supportsLimit()
Does this handler support some form of limiting query results
via a SQL clause?
|
boolean |
supportsLimitOffset()
Does this handler's LIMIT support (if any) additionally
support specifying an offset?
|
boolean |
supportsVariableLimit()
Does this handler support bind variables (i.e., prepared statement
parameters) for its limit/offset?
|
boolean |
useMaxForLimit()
Does the LIMIT clause take a "maximum" row number instead
of a total number of returned rows?
This is easiest understood via an example.
|
protected final String sql
protected final RowSelection selection
public AbstractLimitHandler(String sql, RowSelection selection)
sql
- SQL query.selection
- Selection criteria. null
in case of unlimited number of rows.public boolean supportsLimit()
LimitHandler
supportsLimit
in interface LimitHandler
public boolean supportsLimitOffset()
LimitHandler
supportsLimitOffset
in interface LimitHandler
public boolean supportsVariableLimit()
public boolean bindLimitParametersInReverseOrder()
public boolean bindLimitParametersFirst()
public boolean useMaxForLimit()
public boolean forceLimitUsage()
public int convertToFirstRowValue(int zeroBasedFirstResult)
AbstractLimitHandler(String, RowSelection)
is the zero-based offset.
Dialects which do not supportsVariableLimit()
should take care to perform any needed first-row-conversion
calls prior to injecting the limit values into the SQL string.zeroBasedFirstResult
- The user-supplied, zero-based first row offset.Query.setFirstResult(int)
,
Criteria.setFirstResult(int)
public String getProcessedSql()
LimitHandler
getProcessedSql
in interface LimitHandler
public int bindLimitParametersAtStartOfQuery(PreparedStatement statement, int index) throws SQLException
LimitHandler
bindLimitParametersAtStartOfQuery
in interface LimitHandler
statement
- Statement to which to bind limit parameter values.index
- Index from which to start binding.SQLException
- Indicates problems binding parameter values.public int bindLimitParametersAtEndOfQuery(PreparedStatement statement, int index) throws SQLException
LimitHandler
bindLimitParametersAtEndOfQuery
in interface LimitHandler
statement
- Statement to which to bind limit parameter values.index
- Index from which to start binding.SQLException
- Indicates problems binding parameter values.public void setMaxRows(PreparedStatement statement) throws SQLException
LimitHandler
setMaxRows
in interface LimitHandler
statement
- Statement which number of returned rows shall be limited.SQLException
- Indicates problems while limiting maximum rows returned.protected int bindLimitParameters(PreparedStatement statement, int index) throws SQLException
statement
- Statement to which to bind limit parameter values.index
- Index from which to start binding.SQLException
- Indicates problems binding parameter values.protected int getMaxOrLimit()
Copyright © 2018 JBoss by Red Hat. All rights reserved.