134 Queries with JDOQL Query compilation is generally

134 Queries with JDOQL Query compilation is generally recommended when the same query will be executed multiple times (albeit with different parameter values), or when queries are defined and then stored for later execution. 8.3.1 Query execution The following methods of the Query interface are used to execute a query, each with a different argument list for incoming query parameter values. The methods are all defined to return Object for flexibility in future enhancements to JDOQL. However, under the current version of JDO, all executions result in an unmodifiable collection object. The returned reference should be manually cast to collection by the application developer. Object execute() Object execute(Object p1) Object execute(Object p1, Object p2) Object execute(Object p1, Object p2, Object p3) Execute a query taking zero, one, two, or three parameters. Parameters are positional, and must be passed in the order in which they were declared. Object executeWithArray(Object[] parameters) Execute a query that takes any number of parameters (zero or more). Parameters are positional, and must appear in the array in the order in which they were declared in the query. Object executeWithMap(Map parameters) Execute a query that takes any number of parameters (zero or more). Parameters are named instead of positional . The map contains key and value pairs. Each parameter of the query will be assigned the value corresponding to the map entry with the parameter name as key. 8.3.2 Closing query results void close(Object queryResult) Close the resources associated with a given query result. void closeAll() Close the resources associated with all query results obtained from executions of this query. 8.4 Query examples Although we have yet to discuss the syntax of query filters, we are now in a position to examine some simple queries.

Hint: This post is supported by Gama web hosting hrvatska services

Comments are closed.