Top Description Fields Constructors Methods
org.hibernate.dialect.pagination

public Class SybaseASE157LimitHandler

extends AbstractLimitHandler
Class Inheritance
Imports
java.util.regex.Matcher, .Pattern, org.hibernate.engine.spi.RowSelection

This limit handler is very conservative and is only triggered in simple cases involving a select or select distinct.

Note that if the query already contains "top" just after the select or select distinct, we don't add anything to the query. It might just be a column name but, in any case, we just don't add the top clause and default to the previous behavior so it's not an issue.

Field Summary

Modifier and TypeField and Description
private static final Pattern
private static final Pattern
private static final Pattern

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private static String
insertTop(Matcher matcher, String sql, int top)

public String
processSql(String
the SQL query to process.
sql
,
RowSelection
the selection criteria for rows.
selection
)

Overrides org.hibernate.dialect.pagination.AbstractLimitHandler.processSql.

Implements org.hibernate.dialect.pagination.LimitHandler.processSql.

Return processed SQL query.
public boolean
supportsLimit()

Overrides org.hibernate.dialect.pagination.AbstractLimitHandler.supportsLimit.

Implements org.hibernate.dialect.pagination.LimitHandler.supportsLimit.

Does this handler support some form of limiting query results via a SQL clause?
public boolean
supportsLimitOffset()

Overrides org.hibernate.dialect.pagination.AbstractLimitHandler.supportsLimitOffset.

Implements org.hibernate.dialect.pagination.LimitHandler.supportsLimitOffset.

Does this handler's LIMIT support (if any) additionally support specifying an offset?
public boolean
supportsVariableLimit()

Overrides org.hibernate.dialect.pagination.AbstractLimitHandler.supportsVariableLimit.

Does this handler support bind variables (i.e., prepared statement parameters) for its limit/offset?
public boolean
useMaxForLimit()

Overrides org.hibernate.dialect.pagination.AbstractLimitHandler.useMaxForLimit.

Does the LIMIT clause take a "maximum" row number instead of a total number of returned rows?
Inherited from org.hibernate.dialect.pagination.AbstractLimitHandler:
bindLimitParametersbindLimitParametersAtEndOfQuerybindLimitParametersAtStartOfQuerybindLimitParametersFirstbindLimitParametersInReverseOrderconvertToFirstRowValueforceLimitUsagegetMaxOrLimitsetMaxRows

Field Detail

SELECT_DISTINCT_PATTERNback to summary
private static final Pattern SELECT_DISTINCT_PATTERN
SELECT_PATTERNback to summary
private static final Pattern SELECT_PATTERN
TOP_PATTERNback to summary
private static final Pattern TOP_PATTERN

Constructor Detail

SybaseASE157LimitHandlerback to summary
public SybaseASE157LimitHandler()

Method Detail

insertTopback to summary
private static String insertTop(Matcher matcher, String sql, int top)
processSqlback to summary
public String processSql(String sql, RowSelection selection)

Overrides org.hibernate.dialect.pagination.AbstractLimitHandler.processSql.

Implements org.hibernate.dialect.pagination.LimitHandler.processSql.

Doc from org.hibernate.dialect.pagination.LimitHandler.processSql.

Return processed SQL query.

Parameters
sql:String

the SQL query to process.

selection:RowSelection

the selection criteria for rows.

Returns:String

Query statement with LIMIT clause applied.

Annotations
@Override
supportsLimitback to summary
public boolean supportsLimit()

Overrides org.hibernate.dialect.pagination.AbstractLimitHandler.supportsLimit.

Implements org.hibernate.dialect.pagination.LimitHandler.supportsLimit.

Doc from org.hibernate.dialect.pagination.LimitHandler.supportsLimit.

Does this handler support some form of limiting query results via a SQL clause?

Returns:boolean

True if this handler supports some form of LIMIT.

Annotations
@Override
supportsLimitOffsetback to summary
public boolean supportsLimitOffset()

Overrides org.hibernate.dialect.pagination.AbstractLimitHandler.supportsLimitOffset.

Implements org.hibernate.dialect.pagination.LimitHandler.supportsLimitOffset.

Doc from org.hibernate.dialect.pagination.LimitHandler.supportsLimitOffset.

Does this handler's LIMIT support (if any) additionally support specifying an offset?

Returns:boolean

True if the handler supports an offset within the limit support.

Annotations
@Override
supportsVariableLimitback to summary
public boolean supportsVariableLimit()

Overrides org.hibernate.dialect.pagination.AbstractLimitHandler.supportsVariableLimit.

Doc from org.hibernate.dialect.pagination.AbstractLimitHandler.supportsVariableLimit.

Does this handler support bind variables (i.e., prepared statement parameters) for its limit/offset?

Returns:boolean

True if bind variables can be used; false otherwise.

Annotations
@Override
useMaxForLimitback to summary
public boolean useMaxForLimit()

Overrides org.hibernate.dialect.pagination.AbstractLimitHandler.useMaxForLimit.

Doc from org.hibernate.dialect.pagination.AbstractLimitHandler.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. 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?

Returns:boolean

True if limit is relative from offset; false otherwise.

Annotations
@Override