+

Search Tips   |   Advanced Search

EJB Query ORDER BY clause


The ORDER BY clause specifies an ordering of the objects in the result collection

Use the syntax:

ORDER BY  [ order_element ,]* order_element order_element ::= { path-expression | integer } [ ASC | DESC ]

The path expression must specify a single valued field that is a primitive type of byte, short, int, long, float, double, char or a wrapper type of Byte, Short, Integer, Long, Float, Double, BigDecimal, String, Character, java.util.Calendar, java.util.Date, java.sql.Date, java.sql.Time, java.sql.Timestamp.

ASC specifies ascending order and is the default. DESC specifies descending order.

Integer refers to a selection expression in the SELECT clause.

 

Example: ORDER BY clause

Return department objects in decreasing deptno order:

SELECT  OBJECT(d) FROM  DeptBean d ORDER BY  d.deptno DESC

Return employee objects sorted by department number and name:

SELECT  OBJECT(e) FROM EmpBean e ORDER BY e.dept.deptno ASC,  e.name DESC




Related concepts


EJB query language

 

Related tasks


Use EJB query
Use the dynamic query service