Class SqlOrder


  • public class SqlOrder
    extends Object
    The list of ordering directives for the SQL Processor queries execution. The class layout is based on the Composite design pattern. Instances of this class can be obtained only using one of the factory methods.

    For example there's a table PERSON with two columns - ID and NAME. The META SQL query can be the next one:

     ALL_PEOPLE(QRY)=
       select ID @id, NAME @name
       from PERSON
       {= where
        {& id=:id}
        {& UPPER(name)=:+name}
       }
       {#1 order by ID}
       {#2 order by NAME}
     ;
     

    In the case of the SQL Processor invocation

     SqlEngine sqlEngine = sqlLoader.getQueryEngine("ALL_PEOPLE");
     List<Person> list = sqlEngine.query(session, Person.class, null, SqlOrder.getAscOrder(1));
     
    the output list is sorted in ascending order based on the column ID.

    In the case of the SQL Processor invocation

     SqlEngine sqlEngine = sqlLoader.getQueryEngine("ALL_PEOPLE");
     List<Person> list = sqlEngine.query(session, Person.class, new Object(), SqlOrder.getDescOrder(2));
     
    the output list is sorted in descending order based on the column NAME.

    For more info please see the Tutorials.

    Author:
    Vladimir Hudec
    • Field Detail

      • orderId

        private String orderId
        The ordering id. This value should correspond to the order number in the META SQL query {#NNN order by ...}.
      • orderDirection

        private SqlOrder.Order orderDirection
        The ordering direction (no ordering, ascending or descending).
      • orders

        private List<SqlOrder> orders
        The list of all ordering directives.
    • Constructor Detail

      • SqlOrder

        private SqlOrder()
        Creates a new empty ordering directive list. This constructor is a private one to prevent an instantiation without the help of factory methods.
      • SqlOrder

        private SqlOrder​(String orderId,
                         SqlOrder.Order orderDirection)
        Creates a new ordering directive list. This constructor is a private one to prevent an instantiation without the help of factory methods.
        Parameters:
        orderId - the ordering id
        orderDirection - the ordering direction
    • Method Detail

      • getOrder

        public static SqlOrder getOrder()
        The factory method.
        Returns:
        the empty ordering directive list
      • getAscOrder

        @Deprecated
        public static SqlOrder getAscOrder​(int orderId)
        Deprecated.
        The factory method.
        Parameters:
        orderId - the ordering id
        Returns:
        the ordering directive list with one ascending ordering directive
      • getAscOrderNullsLast

        @Deprecated
        public static SqlOrder getAscOrderNullsLast​(int orderId)
        Deprecated.
        The factory method.
        Parameters:
        orderId - the ordering id
        Returns:
        the ordering directive list with one ascending ordering directive
      • getAscOrder

        public static SqlOrder getAscOrder​(String orderId)
        The factory method.
        Parameters:
        orderId - the ordering id
        Returns:
        the ordering directive list with one ascending ordering directive
      • getAscOrderNullsLast

        public static SqlOrder getAscOrderNullsLast​(String orderId)
        The factory method.
        Parameters:
        orderId - the ordering id
        Returns:
        the ordering directive list with one ascending ordering directive
      • getDescOrder

        @Deprecated
        public static SqlOrder getDescOrder​(int orderId)
        Deprecated.
        The factory method.
        Parameters:
        orderId - the ordering id
        Returns:
        the ordering directive list with one descending ordering directive
      • getDescOrderNullsFirst

        @Deprecated
        public static SqlOrder getDescOrderNullsFirst​(int orderId)
        Deprecated.
        The factory method.
        Parameters:
        orderId - the ordering id
        Returns:
        the ordering directive list with one descending ordering directive
      • getDescOrder

        public static SqlOrder getDescOrder​(String orderId)
        The factory method.
        Parameters:
        orderId - the ordering id
        Returns:
        the ordering directive list with one descending ordering directive
      • getDescOrderNullsFirst

        public static SqlOrder getDescOrderNullsFirst​(String orderId)
        The factory method.
        Parameters:
        orderId - the ordering id
        Returns:
        the ordering directive list with one descending ordering directive
      • getOrder

        @Deprecated
        public static SqlOrder getOrder​(int orderId)
        Deprecated.
        The factory method.
        Parameters:
        orderId - the ordering id. Can be a negative one for a descending ordering directive.
        Returns:
        the ordering directive list with one ascending or descending ordering directive
      • addAscOrder

        @Deprecated
        public SqlOrder addAscOrder​(int orderId)
        Deprecated.
        Adds one more ascending ordering directive into the list of ordering directives.
        Parameters:
        orderId - the ordering id
        Returns:
        the updated ordering directive list
      • addAscOrderNullsLast

        @Deprecated
        public SqlOrder addAscOrderNullsLast​(int orderId)
        Deprecated.
        Adds one more ascending ordering directive into the list of ordering directives.
        Parameters:
        orderId - the ordering id
        Returns:
        the updated ordering directive list
      • addAscOrder

        public SqlOrder addAscOrder​(String orderId)
        Adds one more ascending ordering directive into the list of ordering directives.
        Parameters:
        orderId - the ordering id
        Returns:
        the updated ordering directive list
      • addAscOrderNullsLast

        public SqlOrder addAscOrderNullsLast​(String orderId)
        Adds one more ascending ordering directive into the list of ordering directives.
        Parameters:
        orderId - the ordering id
        Returns:
        the updated ordering directive list
      • addDescOrder

        @Deprecated
        public SqlOrder addDescOrder​(int orderId)
        Deprecated.
        Adds one more descending ordering directive into the list of ordering directives.
        Parameters:
        orderId - the ordering id
        Returns:
        the updated ordering directive list
      • addDescOrderNullsFirst

        @Deprecated
        public SqlOrder addDescOrderNullsFirst​(int orderId)
        Deprecated.
        Adds one more descending ordering directive into the list of ordering directives.
        Parameters:
        orderId - the ordering id
        Returns:
        the updated ordering directive list
      • addDescOrder

        public SqlOrder addDescOrder​(String orderId)
        Adds one more descending ordering directive into the list of ordering directives.
        Parameters:
        orderId - the ordering id
        Returns:
        the updated ordering directive list
      • addDescOrderNullsFirst

        public SqlOrder addDescOrderNullsFirst​(String orderId)
        Adds one more descending ordering directive into the list of ordering directives.
        Parameters:
        orderId - the ordering id
        Returns:
        the updated ordering directive list
      • addOrder

        @Deprecated
        public SqlOrder addOrder​(int orderId)
        Deprecated.
        Adds one more ascending or descending ordering directive into the list of ordering directives.
        Parameters:
        orderId - the ordering id. Can be a negative one for a descending ordering directive.
        Returns:
        the updated ordering directive list
      • getOrderId

        public String getOrderId()
        Returns the ordering id. This value should correspond to the order number in the META SQL query {#NNN order by ...}.
        Returns:
        the ordering id
      • getOrderDirection

        public SqlOrder.Order getOrderDirection()
        Returns the ordering direction (no ordering, ascending or descending).
        Returns:
        the ordering direction
      • getOrders

        public List<SqlOrder> getOrders()
        Returns the list of ordering directives.
        Returns:
        the list of ordering directives
      • toString

        public String toString()
        For debug purposes.
        Overrides:
        toString in class Object
        Returns:
        a String representation for a debug output