Query Namespaces

Two namespaces exist in JDOQL queries; they contain:

  • The names of types

  • The names of fields, parameters, and variables

Parameters and variables are given a name and type when they are declared. The types of the parameters and variables are placed in the first namespace; the parameter and variable names are placed in the latter namespace.

Type Names

When a type name is used (e.g., in a parameter or variable declaration), it must be one of the following:

  • The name of the candidate class

  • The name of a class or interface declared in the java.lang package

  • The name of a class or interface imported by a call to declareImports( )

  • The name of a class or interface in the same package as the candidate class

  • A name imported by a type-import-on-demand declaration, as in "import <package>.*;"

The type namespace automatically includes the name of the candidate class and the names of other classes in the same package. It also automatically includes the names of the public types declared in the java.lang package, just as if there had been a type-import-on-demand declaration (import java.lang.*).

You must include any additional types names necessary for the types of parameters and variables. You import the types into a Query instance by calling the following Query method:

void declareImports(String imports);

The String parameter imports contains one or more import statements, separated by a semicolon. The syntax of the parameter is identical to Java’s import statements. All imports must be declared ...

Get Java Data Objects now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.