public class SQLServer2012LimitHandler extends SQLServer2005LimitHandler
| Constructor and Description |
|---|
SQLServer2012LimitHandler() |
| Modifier and Type | Method and Description |
|---|---|
int |
bindLimitParametersAtEndOfQuery(RowSelection selection,
PreparedStatement statement,
int index)
Bind parameter values needed by the LIMIT clause after original SELECT statement.
|
int |
convertToFirstRowValue(int zeroBasedFirstResult)
Hibernate APIs explicitly state that setFirstResult() should be a zero-based offset.
|
String |
processSql(String sql,
RowSelection selection)
Add a LIMIT clause to the given SQL SELECT (HHH-2655: ROW_NUMBER for Paging)
The LIMIT SQL will look like:
|
boolean |
supportsLimit()
Does this handler support some form of limiting query results
via a SQL clause?
|
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.
|
addTopExpression, bindLimitParametersAtStartOfQuery, encloseWithOuterQuery, fillAliasInSelectClause, supportsLimitOffsetbindLimitParameters, bindLimitParametersFirst, bindLimitParametersInReverseOrder, forceLimitUsage, getMaxOrLimit, setMaxRowspublic boolean supportsLimit()
LimitHandlersupportsLimit in interface LimitHandlersupportsLimit in class SQLServer2005LimitHandlerpublic boolean supportsVariableLimit()
AbstractLimitHandlersupportsVariableLimit in class SQLServer2005LimitHandlerpublic String processSql(String sql, RowSelection selection)
SQLServer2005LimitHandler
WITH query AS (
SELECT inner_query.*
, ROW_NUMBER() OVER (ORDER BY CURRENT_TIMESTAMP) as __hibernate_row_nr__
FROM ( original_query_with_top_if_order_by_present_and_all_aliased_columns ) inner_query
)
SELECT alias_list FROM query WHERE __hibernate_row_nr__ >= offset AND __hibernate_row_nr__ < offset + last
When offset equals 0, only TOP(?) expression is added to the original query.processSql in interface LimitHandlerprocessSql in class SQLServer2005LimitHandlersql - the SQL query to process.selection - the selection criteria for rows.public boolean useMaxForLimit()
AbstractLimitHandleruseMaxForLimit in class SQLServer2005LimitHandlerpublic int convertToFirstRowValue(int zeroBasedFirstResult)
AbstractLimitHandlerAbstractLimitHandler.processSql(String, org.hibernate.engine.spi.RowSelection)
is the zero-based offset. Dialects which do not AbstractLimitHandler.supportsVariableLimit() should take care to perform
any needed first-row-conversion calls prior to injecting the limit values into the SQL string.convertToFirstRowValue in class SQLServer2005LimitHandlerzeroBasedFirstResult - The user-supplied, zero-based first row offset.Query.setFirstResult(int),
Criteria.setFirstResult(int)public int bindLimitParametersAtEndOfQuery(RowSelection selection, PreparedStatement statement, int index) throws SQLException
LimitHandlerbindLimitParametersAtEndOfQuery in interface LimitHandlerbindLimitParametersAtEndOfQuery in class SQLServer2005LimitHandlerselection - 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.Copyright © 2001-2022 Red Hat, Inc. All Rights Reserved.