Package org.sqlproc.engine
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 enum
The enumeration for the ordering directives. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate SqlOrder.Order
The ordering direction (no ordering, ascending or descending).private String
The ordering id.The list of all ordering directives. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
SqlOrder()
Creates a new empty ordering directive list.private
SqlOrder
(String orderId, SqlOrder.Order orderDirection) Creates a new ordering directive list. -
Method Summary
Modifier and TypeMethodDescriptionaddAscOrder
(int orderId) Deprecated.addAscOrder
(String orderId) Adds one more ascending ordering directive into the list of ordering directives.addAscOrderNullsLast
(int orderId) Deprecated.addAscOrderNullsLast
(String orderId) Adds one more ascending ordering directive into the list of ordering directives.addDescOrder
(int orderId) Deprecated.addDescOrder
(String orderId) Adds one more descending ordering directive into the list of ordering directives.addDescOrderNullsFirst
(int orderId) Deprecated.addDescOrderNullsFirst
(String orderId) Adds one more descending ordering directive into the list of ordering directives.addOrder
(int orderId) Deprecated.static SqlOrder
getAscOrder
(int orderId) Deprecated.static SqlOrder
getAscOrder
(String orderId) The factory method.static SqlOrder
getAscOrderNullsLast
(int orderId) Deprecated.static SqlOrder
getAscOrderNullsLast
(String orderId) The factory method.static SqlOrder
getDescOrder
(int orderId) Deprecated.static SqlOrder
getDescOrder
(String orderId) The factory method.static SqlOrder
getDescOrderNullsFirst
(int orderId) Deprecated.static SqlOrder
getDescOrderNullsFirst
(String orderId) The factory method.static SqlOrder
getOrder()
The factory method.static SqlOrder
getOrder
(int orderId) Deprecated.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
The list of all ordering directives.
-
-
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
The factory method.- Returns:
- the empty ordering directive list
-
getAscOrder
Deprecated.The factory method.- Parameters:
orderId
- the ordering id- Returns:
- the ordering directive list with one ascending ordering directive
-
getAscOrderNullsLast
Deprecated.The factory method.- Parameters:
orderId
- the ordering id- Returns:
- the ordering directive list with one ascending ordering directive
-
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
-
getDescOrder
Deprecated.The factory method.- Parameters:
orderId
- the ordering id- Returns:
- the ordering directive list with one descending ordering directive
-
getDescOrderNullsFirst
Deprecated.The factory method.- Parameters:
orderId
- the ordering id- Returns:
- the ordering directive list with one descending ordering directive
-
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
-
getOrder
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.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.Adds one more ascending ordering directive into the list of ordering directives.- Parameters:
orderId
- the ordering id- Returns:
- the updated ordering directive list
-
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
-
addDescOrder
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.Adds one more descending ordering directive into the list of ordering directives.- Parameters:
orderId
- the ordering id- Returns:
- the updated ordering directive list
-
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
-
addOrder
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
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
Returns the list of ordering directives.- Returns:
- the list of ordering directives
-
toString
For debug purposes.
-