Package org.sqlproc.engine
Class SqlOrder
- java.lang.Object
-
- org.sqlproc.engine.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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SqlOrder.Order
The enumeration for the ordering directives.
-
Field Summary
Fields Modifier and Type Field Description private SqlOrder.Order
orderDirection
The ordering direction (no ordering, ascending or descending).private String
orderId
The ordering id.private List<SqlOrder>
orders
The list of all ordering directives.
-
Constructor Summary
Constructors Modifier Constructor Description private
SqlOrder()
Creates a new empty ordering directive list.private
SqlOrder(String orderId, SqlOrder.Order orderDirection)
Creates a new ordering directive list.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description SqlOrder
addAscOrder(int orderId)
Deprecated.SqlOrder
addAscOrder(String orderId)
Adds one more ascending ordering directive into the list of ordering directives.SqlOrder
addAscOrderNullsLast(int orderId)
Deprecated.SqlOrder
addAscOrderNullsLast(String orderId)
Adds one more ascending ordering directive into the list of ordering directives.SqlOrder
addDescOrder(int orderId)
Deprecated.SqlOrder
addDescOrder(String orderId)
Adds one more descending ordering directive into the list of ordering directives.SqlOrder
addDescOrderNullsFirst(int orderId)
Deprecated.SqlOrder
addDescOrderNullsFirst(String orderId)
Adds one more descending ordering directive into the list of ordering directives.SqlOrder
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.SqlOrder.Order
getOrderDirection()
Returns the ordering direction (no ordering, ascending or descending).String
getOrderId()
Returns the ordering id.List<SqlOrder>
getOrders()
Returns the list of ordering directives.String
toString()
For debug purposes.
-
-
-
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).
-
-
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 idorderDirection
- 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
-
-