Module bus.pager

Class DefaultOrderBySqlParser

java.lang.Object
org.miaixz.bus.pager.parsing.DefaultOrderBySqlParser
All Implemented Interfaces:
OrderBySqlParser

public class DefaultOrderBySqlParser extends Object implements OrderBySqlParser
Default implementation of OrderBySqlParser for handling Order by clauses.
Since:
Java 17+
Author:
Kimi Liu
  • Constructor Details

    • DefaultOrderBySqlParser

      public DefaultOrderBySqlParser()
  • Method Details

    • extraOrderBy

      public static List<net.sf.jsqlparser.statement.select.OrderByElement> extraOrderBy(net.sf.jsqlparser.statement.select.Select select)
      Extracts the ORDER BY elements from a SELECT statement and sets the default order by to null.
      Parameters:
      select - the SELECT statement
      Returns:
      the list of OrderByElements
    • converToOrderBySql

      public String converToOrderBySql(String sql, String orderBy)
      Converts a SQL statement to include an ORDER BY clause. If the original SQL contains an ORDER BY clause with parameters, it throws a PageException. If parsing fails, it falls back to appending the ORDER BY clause directly.
      Specified by:
      converToOrderBySql in interface OrderBySqlParser
      Parameters:
      sql - the original SQL statement
      orderBy - the ORDER BY clause to be added
      Returns:
      the modified SQL statement with the ORDER BY clause