Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Enterprise JavaBeans™ Specification, Version 2.0 - Sun Microsystems.pdf
Скачиваний:
14
Добавлен:
24.05.2014
Размер:
2.71 Mб
Скачать

Sun Microsystems Inc.

EJB QL: EJB Query Language for Container Managed Persistence Finder MethodsEnterprise JavaBeans 2.0, Public Draft

EJB QL

Collection_valued_reference_expression ::=

(Single_valued_navigation | Correlation_variable) => collection_valued_cmr_field

10.2.4.7 Input Parameters

The following rules apply to input parameters:

Input parameters are designated by the question mark (?) prefix followed by an integer, for example ?1.

The number of distinct input parameters in an EJB QL query must match the number of input parameters for the finder or select method.

Input parameters must be numbered starting from 1.

An input parameter evaluates to the corresponding type defined in the signature of the finder method or select method for the entity bean.

Input parameters can only be used in conditional expressions involving single valued path expressions.

10.2.4.8Conditional Expression Composition

Arithmetic expressions are composed of themselves, arithmetic operations, references that evaluate to numeric values, and numeric literals.

Conditional expressions are composed of themselves, comparison operations, logical operations, references that evaluate to boolean values, and boolean literals.

A finder expression can be used only within a conditional expression.

Standard bracketing () for ordering expression evaluation is supported.

Whitespace is the same as that defined for Java: space, horizontal tab, and form feed.

The conditional expression is defined as:

conditional_expression ::= conditional_term | conditional_exp OR conditional_term conditional_term ::= conditional_factor | conditional_term AND conditional_factor conditional_factor ::= [ NOT ] conditional-test

conditional_test :: = conditional_primary [IS [ NOT ] {TRUE | FALSE | UNKNOWN}] conditional_primary ::= simple_cond_expression | (conditional_expression) simple_cond_expression ::= comparison_expression | between_expression | like_expression |

5/31/00

206

Sun Microsystems Inc

EJB QL Definition

Enterprise JavaBeans 2.0, Public Draft EJB QL: EJB Query Language for Container

in_expression | null_comparison_expression

[Note to reviewers] Comparison expressions are not be covered in detail here. They are composed of arithmetic, string or boolean expressions composed by the comparison operators.

10.2.4.9 Operators and Operator Precedence

All operators are reserved and cannot be identifier names. The precedence of the operators is listed below:

Logical operators in precedence order are: NOT, AND, OR

Comparison operators are : =, >, >=, <, <=, <> (not equal)

Arithmetic operators in precedence order: +, - unary

*, / multiplication and division +, - addition and subtraction

Arithmetic operations must use Java numeric promotion.

Path expression composition operator .

Remote interface reference operator =>

Other operators used in specific expressions are described in the next sections.

10.2.4.10 Between Expression

Comparison operator [NOT] BETWEEN is used in an arithmetic expression as follows:

arithmetic-expr1 [NOT] BETWEEN arithmetic-expr2 AND arithmetic-expr3.

Examples are:

age

BETWEEN 15 and

19 is equivalent to age >= 15

AND age <= 19

age

NOT BETWEEN 15

and 19 is equivalent to age <

15 OR age > 19

10.2.4.11 In Expression

The comparison operator [NOT] IN is used in a comparison expression as follows:

Single_valued_path_expression [NOT] IN (string-literal1, string-literal2,...)

The Single_valued_path_expression has a String or NULL value.

(Correlation_variable | Single_valued_reference_expression) [NOT] IN (FinderExpression)

207

5/31/00

Sun Microsystems Inc.

EJB QL: EJB Query Language for Container Managed Persistence Finder MethodsEnterprise JavaBeans 2.0, Public Draft

EJB QL

The Correlation_variable must have a remote interface object type value.

Examples are:

Country IN (’ UK’, ’US’, ’France’) is true for UK and false for Peru, and is equivalent to the expression (Country = ’ UK’) OR (Country = ’ US’) OR (Country = ’ France’).

Country NOT IN (’ UK’, ’US’, ’France’) is false for UK and true for Peru, and is equivalent to the expression NOT ((Country = ’ UK’) OR (Country = ’ US’) OR (Country = ’ France’)).

If the value of a reference IN or NOT IN expression is NULL, the value of the operation is unknown.

See Section 10.2.4.14 for information on finder expressions and Section 10.3.3 for an example.

10.2.4.12 Like Expression

The comparison operator [NOT] LIKE is used in a conditional expression as follows:

Single_Valued_Path_expression [NOT] LIKE pattern-value [ESCAPE escape-character]

where Single_valued_path_expression has a String value; pattern-value is a string literal where an underscore (_) stands for any single character; a percent (%) character stands for any sequence of characters (including the empty sequence); and all other characters stand for themselves. The optional escape-character is a single character string literal used to escape the special meaning of the _ and % characters in pattern-value.

Examples are:

phone LIKE ‘12%3’ is true for ‘123’ ‘12993’ and false for ‘1234’

word LIKE ‘l_se’ is true for ‘lose’ and false for ‘loose’

underscored LIKE ‘\_%’ ESCAPE ‘\’ is true for ‘_foo’ and false for ‘bar’

phone NOT LIKE ‘12%3’ is false for ‘123’ and ‘12993’ and true for ‘1234’

If the value of a Single_valued_path_expresion of a LIKE or NOT LIKE operation is NULL, the value of the operation is unknown.

10.2.4.13 Null Comparison Expression

The comparison operator IS NULL is used in a conditional expression as follows:

(Single_valued_path_expression | Correlation_variable) IS NULL

This expression tests whether the value of the Single_valued_path_expression or Correlation_variable is a NULL value, or unknown.

5/31/00

208