11.5. Query Compilation
Prev | Chapter 11. Query | Next

## 11.5. Query Compilation

    public void compile ();

`Query` objects can be compiled via the `compile` method. Compiling a query is a hint to the implementation to optimize an execution plan for the query. During compilation, all query elements are validated; any inconsistencies are reported via a `JDOUserException`.

Query instances can also be serialized. After deserialization, a query cannot be executed, but it retains its candidate class, filter string, imports, parameters, variables, and ordering. A deserialized query can therefore act as a template to create other query instances with the same configuration. This is accomplished through the `PersistenceManager`'s `newQuery(Object template)` method.

Prev | Up | Next
11.4. Executing Queries | Home | Chapter 12. Conclusion