public abstract class AbstractLimitHandler extends Object implements LimitHandler
LimitHandler
interface.Modifier | Constructor and Description |
---|---|
protected |
AbstractLimitHandler() |
Modifier and Type | Method and Description |
---|---|
protected int |
bindLimitParameters(RowSelection selection,
PreparedStatement statement,
int index)
Default implementation of binding parameter values needed by the LIMIT clause.
|
int |
bindLimitParametersAtEndOfQuery(RowSelection selection,
PreparedStatement statement,
int index)
Bind parameter values needed by the LIMIT clause after original SELECT statement.
|
int |
bindLimitParametersAtStartOfQuery(RowSelection selection,
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(RowSelection selection)
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 |
processSql(String sql,
RowSelection selection)
Return processed SQL query.
|
void |
setMaxRows(RowSelection selection,
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.
|
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)
processSql(String, org.hibernate.engine.spi.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 processSql(String sql, RowSelection selection)
LimitHandler
processSql
in interface LimitHandler
sql
- the SQL query to process.selection
- the selection criteria for rows.public int bindLimitParametersAtStartOfQuery(RowSelection selection, PreparedStatement statement, int index) throws SQLException
LimitHandler
bindLimitParametersAtStartOfQuery
in interface LimitHandler
selection
- the selection criteria for rows.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(RowSelection selection, PreparedStatement statement, int index) throws SQLException
LimitHandler
bindLimitParametersAtEndOfQuery
in interface LimitHandler
selection
- the selection criteria for rows.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(RowSelection selection, PreparedStatement statement) throws SQLException
LimitHandler
setMaxRows
in interface LimitHandler
selection
- the selection criteria for rows.statement
- Statement which number of returned rows shall be limited.SQLException
- Indicates problems while limiting maximum rows returned.protected final int bindLimitParameters(RowSelection selection, PreparedStatement statement, int index) throws SQLException
selection
- the selection criteria for rows.statement
- Statement to which to bind limit parameter values.index
- Index from which to start binding.SQLException
- Indicates problems binding parameter values.protected final int getMaxOrLimit(RowSelection selection)
selection
- the selection criteria for rows.Copyright © 2019 JBoss by Red Hat. All rights reserved.