类 SQLServer2012LimitHandler

  • 所有已实现的接口:
    LimitHandler

    public class SQLServer2012LimitHandler
    extends SQLServer2005LimitHandler
    LIMIT clause handler compatible with SQL Server 2012 and later.
    作者:
    Chris Cranford
    • 构造器详细资料

      • SQLServer2012LimitHandler

        public SQLServer2012LimitHandler()
    • 方法详细资料

      • supportsVariableLimit

        public boolean supportsVariableLimit()
        从类复制的说明: AbstractLimitHandler
        Does this handler support bind variables (i.e., prepared statement parameters) for its limit/offset?
        覆盖:
        supportsVariableLimit 在类中 SQLServer2005LimitHandler
        返回:
        True if bind variables can be used; false otherwise.
      • processSql

        public String processSql​(String sql,
                                 RowSelection selection)
        从类复制的说明: SQLServer2005LimitHandler
        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 __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 在接口中 LimitHandler
        覆盖:
        processSql 在类中 SQLServer2005LimitHandler
        参数:
        sql - the SQL query to process.
        selection - the selection criteria for rows.
        返回:
        A new SQL statement with the LIMIT clause applied.
      • useMaxForLimit

        public boolean useMaxForLimit()
        从类复制的说明: AbstractLimitHandler
        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?

        覆盖:
        useMaxForLimit 在类中 SQLServer2005LimitHandler
        返回:
        True if limit is relative from offset; false otherwise.