EJB QL Syntax in BNF Notation

   

The Backus Naur Form (BNF) developed by John Backus and Peter Naur (circa 1960) is the mechanism most often used to define the syntax of a programming language. Using a few meta-symbols, BNF allows the elements of a language to be defined recursively. There are alternate forms of these symbols, which can lead to some confusion if you're not familiar with how to interpret them. To keep things simple, the notation presented in this section follows that used in the EJB 2.0 Specification for the most part. These symbols are defined in Table 8.2.

Table 8.2. BNF Symbols

Symbol

Description

::=

Read as "is defined as."

<>

Angle brackets surround elements that describe portions of the language but aren't part of the actual syntax. Elements without these brackets are written as they actually appear in the language.

[]

Square brackets enclose optional elements.

{}

Braces group elements for clarity.

*

Elements followed by an asterisk can be repeated one or more times.

A logical OR.

EJB QL BNF

This section presents the BNF used to describe EJB QL in the EJB 2.0 Specification. You might be tempted to skip over this because BNF can be confusing at first. However, if you can follow this description of EJB QL, you'll have little difficulty declaring your queries. Just as a DTD governs how you construct a valid deployment descriptor, this BNF is the ultimate guide to correct EJB QL syntax.

 <EJB QL> ::= <select_clause> <from_clause> [<where_clause>]  <from_clause> ::= FROM <identification_variable_declaration>      [, <identification_variable_declaration>]*  <identification_variable_declaration> ::= <collection_member_declaration>       <range_variable_declaration>  <collection_member_declaration> ::= IN (<collection_valued_path_expression>)      [AS] <identifier>  <range_variable_declaration> ::= <abstract_schema_name> [AS] <identifier>  <single_valued_path_expression> ::=      {<single_valued_navigation>  <identification_variable>}.<cmp_field>       <single_valued_navigation>  <single_valued_navigation> ::= <identification_variable>.      [<single_valued_cmr_field>.]*<single_valued_cmr_field>  <collection_valued_path_expression> ::= <identification_variable>.      [<single_valued_cmr_field>.]*<collection_valued_cmr_field>  <select_clause> ::= SELECT [DISTINCT] {<single_valued_path_expression>       OBJECT (<identification_variable>)}  <where_clause> ::= WHERE <conditional_expression>  <conditional_expression> ::= <conditional_term>  <conditional_expression>      OR <conditional_term>  <conditional_term> ::= <conditional_factor>  <conditional_term>      AND <conditional_factor>  <conditional_factor> ::= [NOT] <conditional_test>  <conditional_test> ::= <conditional_primary>  <conditional_primary> ::= <simple_cond_expression>  (<conditional_expression>)  <simple_cond_expression> ::= <comparison_expression>  <between_expression>       <like_expression>  <in_expression>  <null_comparison_expression>       <empty_collection_comparison_expression>  <collection_member_expression>  <between_expression> ::= <arithmetic_expression> [NOT] BETWEEN      <arithmetic_expression> AND <arithmetic_expression>  <in_expression> ::= <single_valued_path_expression>      [NOT] IN (<string_literal> [, <string_literal>]*)  <like_expression> ::= <single_valued_path_expression>      [NOT] LIKE <pattern_value> [ESCAPE <escape-character>]  <null_comparison_expression> ::= <single_valued_path_expression> IS [NOT] NULL  <empty_collection_comparison_expression> ::=      <collection_valued_path_expression> IS [NOT] EMPTY  <collection_member_expression> ::=  {<single_valued_navigation>  <identification_variable>       <input_parameter>} [NOT] MEMBER [OF]      <collection_valued_path_expression>  <comparison_expression> ::=      <string_value> { =  <>} <string_expression>       <boolean_value> { =  <>} <boolean_expression>}       <datetime_value> { =  <>  >  < } <datetime_expression>       <entity_bean_value> { =  <> } <entity_bean_expression>       <arithmetic_value> <comparison_operator> <single_value_designator>  <arithmetic_value> ::= <single_valued_path_expression>       <functions_returning_numerics>  <single_value_designator> ::= <scalar_expression>  <comparison_operator> ::=      =  >  >=  <  <=  <>  <scalar_expression> ::= <arithmetic_expression>  <arithmetic_expression> ::= <arithmetic_term>  <arithmetic_expression>      { +  - } <arithmetic_term>  <arithmetic_term> ::= <arithmetic_factor>  <arithmetic_term>      { *  / } <arithmetic_factor>  <arithmetic_factor> ::= { +  - } <arithmetic_primary>  <arithmetic_primary> ::= <single_valued_path_expression>  <literal>       (<arithmetic_expression>)  <input_parameter>       <functions_returning_numerics>  <string_value> ::= <single_valued_path_expression>       <functions_returning_strings>  <string_expression> ::= <string_primary>  <input_expression>  <string_primary> ::= <single_valued_path_expression>  <literal>       (<string_expression>)  <functions_returning_strings>  <datetime_value> ::= <single_valued_path_expression>  <datetime_expression> ::= <datetime_value>  <input_parameter>  <boolean_value> ::= <single_valued_path_expression>  <boolean_expression> ::= <single_valued_path_expression>  <literal>       <input_parameter>  <entity_bean_value> ::= <single_valued_navigation>       <identification_variable>  <entity_bean_expression> ::= <entity_bean_value>  <input_parameter>  <functions_returning_strings> ::=      CONCAT (<string_expression>, <string_expression>)       SUBSTRING (<string_expression>, <arithmetic_expression>,          <arithmetic_expression>)  <functions_returning_numerics> ::=      LENGTH (<string_expression>)       LOCATE (<string_expression>, <string_expression>          [,<arithmetic_expression>])       ABS (<arithmetic_expression>)       SQRT (<arithmetic_expression>) 


Special Edition Using Enterprise JavaBeans 2.0
Special Edition Using Enterprise JavaBeans 2.0
ISBN: 0789725673
EAN: 2147483647
Year: 2000
Pages: 223

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net