Class LegacyLimitHandler

  • All Implemented Interfaces:
    LimitHandler

    public class LegacyLimitHandler
    extends AbstractLimitHandler
    Limit handler that delegates all operations to the underlying dialect.
    • Constructor Detail

      • LegacyLimitHandler

        public LegacyLimitHandler​(Dialect dialect)
        Constructs a LegacyLimitHandler
        Parameters:
        dialect - The dialect
    • Method Detail

      • supportsVariableLimit

        public boolean supportsVariableLimit()
        Description copied from class: AbstractLimitHandler
        Does this handler support bind variables (i.e., prepared statement parameters) for its limit/offset?
        Overrides:
        supportsVariableLimit in class AbstractLimitHandler
        Returns:
        True if bind variables can be used; false otherwise.
      • bindLimitParametersInReverseOrder

        public boolean bindLimitParametersInReverseOrder()
        Description copied from class: AbstractLimitHandler
        ANSI SQL defines the LIMIT clause to be in the form LIMIT offset, limit. Does this dialect require us to bind the parameters in reverse order?
        Overrides:
        bindLimitParametersInReverseOrder in class AbstractLimitHandler
        Returns:
        true if the correct order is limit, offset
      • bindLimitParametersFirst

        public boolean bindLimitParametersFirst()
        Description copied from class: AbstractLimitHandler
        Does the LIMIT clause come at the start of the SELECT statement, rather than at the end?
        Overrides:
        bindLimitParametersFirst in class AbstractLimitHandler
        Returns:
        true if limit parameters should come before other parameters
      • useMaxForLimit

        public boolean useMaxForLimit()
        Description copied from class: 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?

        Overrides:
        useMaxForLimit in class AbstractLimitHandler
        Returns:
        True if limit is relative from offset; false otherwise.
      • forceLimitUsage

        public boolean forceLimitUsage()
        Description copied from class: AbstractLimitHandler
        Generally, if there is no limit applied to a Hibernate query we do not apply any limits to the SQL query. This option forces that the limit be written to the SQL query.
        Overrides:
        forceLimitUsage in class AbstractLimitHandler
        Returns:
        True to force limit into SQL query even if none specified in Hibernate query; false otherwise.
      • processSql

        public java.lang.String processSql​(java.lang.String sql,
                                           RowSelection selection)
        Description copied from interface: LimitHandler
        Return processed SQL query.
        Specified by:
        processSql in interface LimitHandler
        Overrides:
        processSql in class AbstractLimitHandler
        Parameters:
        sql - the SQL query to process.
        selection - the selection criteria for rows.
        Returns:
        Query statement with LIMIT clause applied.