Skip Headers

Oracle TopLink Developer's Guide 10g Release 3 (10.1.3) B13593-01 |
| Home | Solution Area | Contents | Index

Previous | Next |

# Configuring Named Queries at the Session Level

A named query is a TopLink query that you create and store, by name, in a session for later retrieval and execution. Named queries improve application performance, because they are prepared once and they (and all their associated supporting objects) can be efficiently reused thereafter making them well-suited for frequently executed operations.

If a named query is global to a project, configure it at the session level. Alternatively, you can configure a named query at the descriptor level (see "Configuring Named Queries at the Descriptor Level").

Use named queries to specify SQL, EJB QL, or TopLink `Expression` queries to access your data source.

Table 77-17 summarizes which sessions support named query configuration.

Table 77-17 Session Support for Named Queries

Session | Using TopLink Workbench | Using Java
--- | --- | ---
Server and Client Sessions |  |
Session Broker and Client Sessions |  |
Database Sessions |  |

After you create a named query, you can execute it by name on the TopLink session (see "Using Named Queries").

For more information about named queries, see "Named Queries".

## Using Java

You can store a query by name in a `Session` using `Session` method `addQuery(String name, DatabaseQuery query)`.