| Modifier and Type | Class and Description |
|---|---|
| pack-priv static class |
| Modifier and Type | Field and Description |
|---|---|
| private static final Pattern | |
| private static final Pattern | |
| private static final String | |
| private static final Pattern | |
| private static final String | |
| private static final Pattern | |
| private boolean | |
| private static final String | |
| private static final Pattern | |
| private static final String | |
| private static final String | |
| private static final Pattern | |
| private static final String | |
| private static final Pattern | |
| private static final String | |
| private static final String | |
| private boolean | |
| private static final Pattern | |
| private static final Pattern | |
| private static final Pattern | |
| private static final Pattern | |
| private static final Pattern | |
| private static final Pattern |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| protected void | addTopExpression(StringBuilder
SQL query. sql, int the offset where top expression pattern matching should begin. offset)Adds |
| private int | Returns: the position immediately after the CTE inner query plus 1.The sql buffer. sql, int The offset where to begin advancing the position from. offset)Advances over the CTE inner query that is contained inside matching '(' and ')'. |
| 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 | bindLimitParametersAtStartOfQuery(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. |
| private static Pattern | Returns: CompiledPattern.String search pattern. pattern, boolean whether to apply a word boundary restriction. wordBoundary)Builds a pattern that can be used to find matches of case-insensitive matches based on the search pattern that is not enclosed in parenthesis. |
| public int | convertToFirstRowValue(int
The user-supplied, zero-based first row offset. zeroBasedFirstResult)Overrides org. |
| protected void | encloseWithOuterQuery(StringBuilder
SQL query. sql, int SQL query offset. offset)Encloses original SQL statement with outer query that provides __row__ column. |
| protected String | Returns: List of aliases separated with comas or *.SQL query. sb, int the starting offset. offset)Adds missing aliases in provided SELECT clause and returns coma-separated list of them. |
| private static List | Returns: list ofIgnoreRange objects, never null.The SQL buffer. sql)Generates a list of |
| private String | |
| private int | Returns: the start position where the column list begins.the string builder sql. sb, int the starting offset. offset)Get the start position for where the column list begins. |
| private int | Returns: the position whereselect is found.the string builder sql. sb, int the starting offset in buffer. offset)Get the select start position. |
| private int | Returns: the index where to begin parsing.The sql buffer. sql)Get the starting point for the limit handler to begin injecting and transforming the SQL. |
| private static boolean | Returns: true if the position is to ignored/skipped, false otherwise.list of ignoreRangeList,IgnoreRange objects deduced from the SQL buffer.the position to determine whether is ignorable. position)Returns whether the specified |
| private int | Returns: the offset where the CTE SELECT clause begins.The sql buffer. sql, int The offset to begin pattern matching. offset)Steps through the SQL buffer from the specified offset and performs a series of pattern matches. |
| public String | Returns: A new SQL statement with the LIMIT clause applied.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
|
| private boolean | Returns: true when expression selects multiple columns, false otherwise.Select expression. expression)
|
| private static int | Returns: Position of the first match, or -1 if not found.String to search. sb, final Pattern Compiled search pattern. pattern, int The index from which to start the search. fromIndex)Returns index of the first case-insensitive match of search pattern that is not enclosed in parenthesis. |
| public boolean | supportsLimit()
Overrides org. Implements org. |
| public boolean | supportsLimitOffset()
Overrides org. Implements org. |
| public boolean | supportsVariableLimit()
Overrides org. |
| public boolean | useMaxForLimit()
Overrides org. |
| ALIAS_PATTERN | back to summary |
|---|---|
| private static final Pattern ALIAS_PATTERN | |
| COMMA_PATTERN | back to summary |
|---|---|
| private static final Pattern COMMA_PATTERN | |
| DISTINCT | back to summary |
|---|---|
| private static final String DISTINCT | |
| DISTINCT_PATTERN | back to summary |
|---|---|
| private static final Pattern DISTINCT_PATTERN | |
| FROM | back to summary |
|---|---|
| private static final String FROM | |
| FROM_PATTERN | back to summary |
|---|---|
| private static final Pattern FROM_PATTERN | |
| isCTE | back to summary |
|---|---|
| private boolean isCTE | |
| ORDER_BY | back to summary |
|---|---|
| private static final String ORDER_BY | |
| ORDER_BY_PATTERN | back to summary |
|---|---|
| private static final Pattern ORDER_BY_PATTERN | |
| SELECT | back to summary |
|---|---|
| private static final String SELECT | |
| SELECT_DISTINCT | back to summary |
|---|---|
| private static final String SELECT_DISTINCT | |
| SELECT_DISTINCT_PATTERN | back to summary |
|---|---|
| private static final Pattern SELECT_DISTINCT_PATTERN | |
| SELECT_DISTINCT_SPACE | back to summary |
|---|---|
| private static final String SELECT_DISTINCT_SPACE | |
| SELECT_PATTERN | back to summary |
|---|---|
| private static final Pattern SELECT_PATTERN | |
| SELECT_SPACE | back to summary |
|---|---|
| private static final String SELECT_SPACE | |
| SPACE_NEWLINE_LINEFEED | back to summary |
|---|---|
| private static final String SPACE_NEWLINE_LINEFEED | |
| topAdded | back to summary |
|---|---|
| private boolean topAdded | |
| WITH_AS | back to summary |
|---|---|
| private static final Pattern WITH_AS | |
| WITH_COLUMN_NAMES_END | back to summary |
|---|---|
| private static final Pattern WITH_COLUMN_NAMES_END | |
| WITH_COLUMN_NAMES_START | back to summary |
|---|---|
| private static final Pattern WITH_COLUMN_NAMES_START | |
| WITH_COMMA | back to summary |
|---|---|
| private static final Pattern WITH_COMMA | |
| WITH_CTE | back to summary |
|---|---|
| private static final Pattern WITH_CTE | |
| WITH_EXPRESSION_NAME | back to summary |
|---|---|
| private static final Pattern WITH_EXPRESSION_NAME | |
| SQLServer2005LimitHandler | back to summary |
|---|---|
| public SQLServer2005LimitHandler() Constructs a SQLServer2005LimitHandler | |
| addTopExpression | back to summary |
|---|---|
| protected void addTopExpression(StringBuilder sql, int offset) Adds
| |
| advanceOverCTEInnerQuery | back to summary |
|---|---|
| private int advanceOverCTEInnerQuery(StringBuilder sql, int offset) Advances over the CTE inner query that is contained inside matching '(' and ')'.
| |
| 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.
| |
| bindLimitParametersAtStartOfQuery | back to summary |
|---|---|
| public int bindLimitParametersAtStartOfQuery(RowSelection selection, PreparedStatement statement, int index) throws SQLException Overrides org. Implements org. Doc from org. Bind parameter values needed by the LIMIT clause before original SELECT statement.
| |
| buildShallowIndexPattern | back to summary |
|---|---|
| private static Pattern buildShallowIndexPattern(String pattern, boolean wordBoundary) Builds a pattern that can be used to find matches of case-insensitive matches based on the search pattern that is not enclosed in parenthesis. | |
| 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
| |
| encloseWithOuterQuery | back to summary |
|---|---|
| protected void encloseWithOuterQuery(StringBuilder sql, int offset) Encloses original SQL statement with outer query that provides __row__ column.
| |
| fillAliasInSelectClause | back to summary |
|---|---|
| protected String fillAliasInSelectClause(StringBuilder sb, int offset) Adds missing aliases in provided SELECT clause and returns coma-separated list of them. If query takes advantage of expressions like * or {table}.* inside SELECT clause, method returns *.
| |
| generateIgnoreRanges | back to summary |
|---|---|
| private static List Generates a list of
| |
| getAlias | back to summary |
|---|---|
| private String getAlias(String expression) Returns alias of provided single column selection or | |
| getSelectColumnsStartPosition | back to summary |
|---|---|
| private int getSelectColumnsStartPosition(StringBuilder sb, int offset) Get the start position for where the column list begins.
| |
| getSelectStartPosition | back to summary |
|---|---|
| private int getSelectStartPosition(StringBuilder sb, int offset) Get the select start position.
| |
| getStatementIndex | back to summary |
|---|---|
| private int getStatementIndex(StringBuilder sql) Get the starting point for the limit handler to begin injecting and transforming the SQL.
For non-CTE queries, this is offset 0. For CTE queries, this will be where the CTE's
SELECT clause begins (skipping all query definitions, column definitions and expressions).
This method also sets
| |
| isPositionIgnorable | back to summary |
|---|---|
| private static boolean isPositionIgnorable(List<SQLServer2005LimitHandler. Returns whether the specified
| |
| locateQueryInCTEStatement | back to summary |
|---|---|
| private int locateQueryInCTEStatement(StringBuilder sql, int offset) Steps through the SQL buffer from the specified offset and performs a series of pattern matches. The method locates where the CTE SELECT clause begins and returns that offset from the SQL buffer.
| |
| processSql | back to summary |
|---|---|
| public String processSql(String sql, RowSelection selection) Overrides org. Implements 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.
| |
| selectsMultipleColumns | back to summary |
|---|---|
private boolean selectsMultipleColumns(String expression)
| |
| shallowIndexOfPattern | back to summary |
|---|---|
| private static int shallowIndexOfPattern(final StringBuilder sb, final Pattern pattern, int fromIndex) Returns index of the first case-insensitive match of search pattern that is not enclosed in parenthesis.
| |
| 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?
| |
| supportsLimitOffset | back to summary |
|---|---|
| public boolean supportsLimitOffset() Overrides org. Implements org. Doc from org. Does this handler's LIMIT support (if any) additionally support specifying an offset?
| |
| 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?
| |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv boolean |
| IgnoreRange | back to summary |
|---|---|
| pack-priv IgnoreRange(int start, int end) | |
| isWithinRange | back to summary |
|---|---|
| pack-priv boolean isWithinRange(int position) | |