Skip Headers
Oracle TopLink Developer's Guide
10g Release 3 (10.1.3)
B13593-01
  Go To Documentation Library
Home
Go To Product List
Solution Area
Go To Table Of Contents
Contents
Go To Index
Index

Previous
Previous
Next
Next
 

Using Named Queries

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.

You can configure named queries at the session (see "Configuring Named Queries at the Session Level") or descriptor (see "Configuring Named Queries at the Descriptor Level") level.

For a session-level named query, you can execute the query using any of the following Session API calls:

Example 98-37 Executing a Session-Level Named Query

Vector args = new Vector();
args.add("Sarah");
Employee sarah = (Employee)session.executeQuery(
    "employeeReadByFirstName",
    args
);

For a descriptor-level named query, you can execute the query using any of the following Session API calls, as Example 98-38 shows:

Example 98-38 Executing a Descriptor Level Named Query

Vector args = new Vector();
args.add("Sarah");
Employee sarah = (Employee)session.executeQuery(
    "ReadByFirstName",
    Employee.class,
    args
);

For more information, see "Named Queries"