| Modifier and Type | Field and Description |
|---|---|
| private boolean |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| private String | |
| public int | bindLimitParametersAtEndOfQuery(RowSelection
the selection criteria for rows. selection, PreparedStatement Statement to which to bind limit parameter values. statement, int Index from which to start binding. index)Overrides org. Implements org. |
| public int | convertToFirstRowValue(int
The user-supplied, zero-based first row offset. zeroBasedFirstResult)Overrides org. |
| private int | |
| private String | |
| private boolean | |
| public String | processSql(String
the SQL query to process. sql, RowSelection the selection criteria for rows. selection)Overrides org. Implements org.
WITH query AS (
SELECT inner_query.*
, ROW_NUMBER() OVER (ORDER BY CURRENT_TIMESTAMP) as __row__
FROM ( original_query_with_top_if_order_by_present_and_all_aliased_columns ) inner_query
)
SELECT alias_list FROM query WHERE __row__ >= offset AND __row__ < offset + last
|
| public boolean | supportsLimit()
Overrides org. Implements org. |
| public boolean | supportsVariableLimit()
Overrides org. |
| public boolean | useMaxForLimit()
Overrides org. |
| usedOffsetFetch | back to summary |
|---|---|
| private boolean usedOffsetFetch | |
| SQLServer2012LimitHandler | back to summary |
|---|---|
| public SQLServer2012LimitHandler() | |
| applyOffsetFetch | back to summary |
|---|---|
| private String applyOffsetFetch(RowSelection selection, String sql, int position) | |
| bindLimitParametersAtEndOfQuery | back to summary |
|---|---|
| public int bindLimitParametersAtEndOfQuery(RowSelection selection, PreparedStatement statement, int index) throws SQLException Overrides org. Implements org. Doc from org. Bind parameter values needed by the LIMIT clause after original SELECT statement.
| |
| convertToFirstRowValue | back to summary |
|---|---|
| public int convertToFirstRowValue(int zeroBasedFirstResult) Overrides org. Doc from org. Hibernate APIs explicitly state that setFirstResult() should be a zero-based offset. Here we allow the Dialect a chance to convert that value based on what the underlying db or driver will expect. Note what gets passed into
| |
| getInsertPosition | back to summary |
|---|---|
| private int getInsertPosition(String sql) | |
| getOffsetFetch | back to summary |
|---|---|
| private String getOffsetFetch(RowSelection selection) | |
| hasOrderBy | back to summary |
|---|---|
| private boolean hasOrderBy(String sql) | |
| processSql | back to summary |
|---|---|
| public String processSql(String sql, RowSelection selection) Overrides org. Implements org. Doc from org. Add a LIMIT clause to the given SQL SELECT (HHH-2655: ROW_NUMBER for Paging) The LIMIT SQL will look like:
WITH query AS (
SELECT inner_query.*
, ROW_NUMBER() OVER (ORDER BY CURRENT_TIMESTAMP) as __row__
FROM ( original_query_with_top_if_order_by_present_and_all_aliased_columns ) inner_query
)
SELECT alias_list FROM query WHERE __row__ >= offset AND __row__ < offset + last
When offset equals 0, only TOP(?) expression is added to the original query.
| |
| supportsLimit | back to summary |
|---|---|
| public boolean supportsLimit() Overrides org. Implements org. Doc from org. Does this handler support some form of limiting query results via a SQL clause?
| |
| supportsVariableLimit | back to summary |
|---|---|
| public boolean supportsVariableLimit() Overrides org. Doc from org. Does this handler support bind variables (i.e., prepared statement parameters) for its limit/offset?
| |
| useMaxForLimit | back to summary |
|---|---|
| public boolean useMaxForLimit() Overrides org. Doc from org. Does the LIMIT clause take a "maximum" row number instead of a total number of returned rows? This is easiest understood via an example. Consider you have a table with 20 rows, but you only want to retrieve rows number 11 through 20. Generally, a limit with offset would say that the offset = 11 and the limit = 10 (we only want 10 rows at a time); this is specifying the total number of returned rows. Some dialects require that we instead specify offset = 11 and limit = 20, where 20 is the "last" row we want relative to offset (i.e. total number of rows = 20 - 11 = 9) So essentially, is limit relative from offset? Or is limit absolute?
| |