Skip Headers

# Configuring Named Queries at the Descriptor Level

Previous

Next

A named query is a TopLink query that you create and store, by name, in a descriptor's `DescriptorQueryManager` 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 `Class`, configure it at the descriptor level. Alternatively, you can configure a named query at the session level (see "Configuring Named Queries at the Session Level").

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

For entity bean descriptors, you must define a named query for every finder defined for the corresponding entity bean.

Using TopLink Workbench, you can configure named queries for a subset of query types and store them in a descriptor's `DescriptorQueryManager` (see "Using TopLink Workbench").

Using Java, you can create named queries for all query types and store them in a descriptor's `DescriptorQueryManager` (see "Using Java").

Table: Descriptor Support for Read Only summarizes which descriptors support named query configuration.

Descriptor Support for Named Queries

Descriptor | Using TopLink Workbench | Using Java
--- | --- | ---
Relational DescriptorsFoot 1 |  |
Object-Relational Descriptors |  |
EIS DescriptorFoot 2 |  |
XML Descriptors |  |

Footnote 1 Relational class descriptors only (see "Relational Class Descriptors").

Footnote 2 EIS root descriptors only (see "EIS Root Descriptors").

For CMP projects, the `ejb-jar.xml` file stores query lists. You can define the queries in the file, and then read them into TopLink Workbench, or define them on the Queries tab and write them to the file. See "Working With the ejb-jar.xml File" for more information.

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

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