Class SqlOrder
java.lang.Object
org.sqlproc.engine.SqlOrder
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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThe enumeration for the ordering directives. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate SqlOrder.OrderThe ordering direction (no ordering, ascending or descending).private StringThe ordering id.The list of all ordering directives. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateSqlOrder()Creates a new empty ordering directive list.privateSqlOrder(String orderId, SqlOrder.Order orderDirection) Creates a new ordering directive list. -
Method Summary
Modifier and TypeMethodDescriptionaddAscOrder(int orderId) Adds one more ascending ordering directive into the list of ordering directives.addAscOrder(String orderId) Adds one more ascending ordering directive into the list of ordering directives.addAscOrderNullsLast(int orderId) Adds one more ascending ordering directive into the list of ordering directives.addAscOrderNullsLast(String orderId) Adds one more ascending ordering directive into the list of ordering directives.addDescOrder(int orderId) Adds one more descending ordering directive into the list of ordering directives.addDescOrder(String orderId) Adds one more descending ordering directive into the list of ordering directives.addDescOrderNullsFirst(int orderId) Adds one more descending ordering directive into the list of ordering directives.addDescOrderNullsFirst(String orderId) Adds one more descending ordering directive into the list of ordering directives.addOrder(int orderId) Adds one more ascending or descending ordering directive into the list of ordering directives.static SqlOrdergetAscOrder(int orderId) The factory method.static SqlOrdergetAscOrder(String orderId) The factory method.static SqlOrdergetAscOrderNullsLast(int orderId) The factory method.static SqlOrdergetAscOrderNullsLast(String orderId) The factory method.static SqlOrdergetDescOrder(int orderId) The factory method.static SqlOrdergetDescOrder(String orderId) The factory method.static SqlOrdergetDescOrderNullsFirst(int orderId) The factory method.static SqlOrdergetDescOrderNullsFirst(String orderId) The factory method.static SqlOrdergetOrder()The factory method.static SqlOrdergetOrder(int orderId) The factory method.Returns the ordering direction (no ordering, ascending or descending).Returns the ordering id.Returns the list of ordering directives.toString()For debug purposes.
-
Field Details
-
orderId
The ordering id. This value should correspond to the order number in the META SQL query {#NNN order by ...}. -
orderDirection
The ordering direction (no ordering, ascending or descending). -
orders
-
-
Constructor Details
-
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
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 idorderDirection- the ordering direction
-
-
Method Details
-
getOrder
-
getAscOrder
The factory method.- Parameters:
orderId- the ordering id- Returns:
- the ordering directive list with one ascending ordering directive
-
getAscOrderNullsLast
The factory method.- Parameters:
orderId- the ordering id- Returns:
- the ordering directive list with one ascending ordering directive
-
getAscOrder
-
getAscOrderNullsLast
-
getDescOrder
The factory method.- Parameters:
orderId- the ordering id- Returns:
- the ordering directive list with one descending ordering directive
-
getDescOrderNullsFirst
The factory method.- Parameters:
orderId- the ordering id- Returns:
- the ordering directive list with one descending ordering directive
-
getDescOrder
-
getDescOrderNullsFirst
-
getOrder
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
Adds one more ascending ordering directive into the list of ordering directives.- Parameters:
orderId- the ordering id- Returns:
- the updated ordering directive list
-
addAscOrderNullsLast
Adds one more ascending ordering directive into the list of ordering directives.- Parameters:
orderId- the ordering id- Returns:
- the updated ordering directive list
-
addAscOrder
-
addAscOrderNullsLast
-
addDescOrder
Adds one more descending ordering directive into the list of ordering directives.- Parameters:
orderId- the ordering id- Returns:
- the updated ordering directive list
-
addDescOrderNullsFirst
Adds one more descending ordering directive into the list of ordering directives.- Parameters:
orderId- the ordering id- Returns:
- the updated ordering directive list
-
addDescOrder
-
addDescOrderNullsFirst
-
addOrder
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
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
Returns the ordering direction (no ordering, ascending or descending).- Returns:
- the ordering direction
-
getOrders
-
toString
-