130 Queries with JDOQL The philosophy of JDOQL

Constructing queries 131 . Identifier Namespace. All parameter names, variable names, and persistent field names reside in this namespace. The persistent field names include all persistent fields of all classes referenced in the query. Thus it is not legal to define a parameter or variable with the same name as a persistent field of the candidate class or other persistence-capable class referenced in the query. Nor is it legal to define both a parameter and a variable with the same name. JDOQL is very Java-like in syntax and therefore easy for Java developers to master. Nevertheless, the query interface has been designed so that it can be used with an alternative query language if the application so chooses, presuming that this alternative language is supported by the implementation. 8.2 Constructing queries A persistence manager acts as the factory for queries, and provides a set of newQuery() methods by which an application can construct queries. These methods are detailed below. Query newQuery() Constructs a new query instance, bound to the current persistence manager. All of the query s properties can then be set directly, including the query language. Query newQuery(Object query) Constructs a query instance from another query. The new query shares the original query s elements except for the candidate collection or extent. The new query is bound to the persistence manager on which newQuery() was executed, even though the original query may have been obtained from a different persistence manager. This, combined with the requirement that all query implementation classes are serializable, facilitates the construction of a new query based on one earlier constructed against a different JDO implementation. This method presumes that the implementation s default query language (typically JDOQL) is to be used. Query newQuery(String language, Object query) Constructs a new query from an existing query using the specified query language. Query newQuery(Class cls) Construct a new query with the specified candidate class. Query newQuery(Extent cln) Construct a new query with the candidate class derived from the Extent, and a candidate collection comprised of all persistent instances of the Extent. Query newQuery(Class cls, Collection cln) Construct a new query with the specified candidate class and candidate collection. The collection may contain zero or more objects, all of which must be instances of the candidate class.
Note: If you are looking for good and quality webspace to host and run your java application check Actions java hosting services

Comments are closed.