| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
The WHERE and ORDER BY clauses are optional.
SELECTSpecifies the query's values.
FROMSpecifies the query's schema and variables.
WHERERestricts the selected values to those matching a boolean expression.
Sorts the returned values. The sorts the results of a query by an expression. Because the database sorts the results, ORDER BY can often be more efficient than sorting in Java in addition to being clearer. The ORDER BY expression may use a string argument, like ?3. This allows the ORDER BY field to be selected by the argument.
For a collection-valued query, returns items starting from the offset value. Only integer constants and integer arguments like ?3 are allowed. OFFSET is generally used in combination with LIMIT to select a slice of a large database query. Depending on the database, this may require an ORDER BY to make the results consistent. Unless you specify ORDER BY, databases are allowed to return query results in any order. So using OFFSET without ORDER BY name return different results even when called with the same query.
For a collection-valued query, limits the number of items returned. Only integer constants and integer arguments like ?3 are allowed. LIMIT is generally used with OFFSET to handle large database queries which may have multiple return pages. Depending on the database, LIMIT may require an ORDER BY to make the results consistent. Unless you specify ORDER BY, databases are allowed to return query results in any order. So using OFFSET without ORDER BY name return different results even when called with the same query.
bean-expr . cmp-fieldSelects a field value from an entity bean. The type of the expression is the type of the cmp-field.
bean-expr . cmr-fieldSelects relation bean from an entity bean. The type of the expression is the bean result. Because the value of the expression is an entity bean, the expression can be used in a further path expression.
?nA find or select method argument. The value of the argument is inserted into the expression. The count is 1-based, so a method with a single argument will use . The type of the expression is the type of the method argument.
expr + exprArithmetic expressions. Adds, subtracts, multiplies or divides two expressions, returning a numeric expression. The sub-expressions must have numeric values.
expr = exprComparison expressions. Compares two expressions, returning a boolean expression. The two expressions for an equality comparison must have compatible types. The expressions for less-than comparison must have numeric values.
IS [NOT] NULLTests for a null value. IS NULL can be used both for SQL null values and for null relation values. The following example shows the case where c.teacher is a relation to a Teacher object. It will select courses with no assigned teacher.
expr AND exprBoolean and expression. Evaluates to true if both expressions are true. Both expressions must be boolean and the result is a boolean. expr OR exprBoolean or expression. Evaluates to true if either expression is true. Both expressions must be boolean and the result is a boolean. NOT exprBoolean not expression. The expression and the result are boolean expressions. fun_name(expr, ...)Applies a function to the expression arguments. Resin-CMP will allow the functions defined in the JDBC 2.0 spec, but the EJB-QL spec only defines the following functions:
Additional functions can be added using the query-function tag in the resin-ejb configuration file. The following functions are known to Resin-CMP:
|