Skip Headers

# Configuring Named Query Parameterized SQL and Statement Caching at the Project Level

Previous

Next

You can configure TopLink to use parameterized SQL and prepared statement caching for all named queries and finders.

These setting apply only to named queries (see "Named Queries")–not to all queries in general or write operations.

Generally, to use parameterized SQL, you should configure it on the session's login (see "Configuring JDBC Options"). Configuring at the session level ensures that all queries will use parameterized SQL.

Note: For applications using a J2EE data source or external connection pool, you must configure statement caching in the J2EE server's data source–not in TopLink.

Table: Project Support for Default Named Query Caching and Binding summarizes which projects support query statement caching and binding configuration.

Project Support for Default Named Query Caching and Binding

Descriptor | Using TopLink Workbench | Using Java
--- | --- | ---
Relational Projects |  |
EIS Projects |  |
XML Projects |  |

This section describes configuring statement caching and binding options at the project level. This configuration applies to all named queries you create on the descriptors in this project.

You can also configure named query statement caching and binding options at the query level to override this project-level configuration on a query-by-query basis (see "Configuring Named Query Options").

Using parameterized SQL, you can create and store queries that are complete except for one or more bound parameters. The TopLink runtime binds the current parameter values when executing the query. This approach avoids the preparation of SQL execution and, thus, improves the performance of frequently executed SQL statements.

By default, Oracle TopLink writes data directly into its generated SQL, and does not use parameterized SQL. This is due to the fact that many JDBC drivers do not fully support parameter binding and impose restrictive size or type limits. For more information, see "Parameterized SQL (Binding) and Prepared Statement Caching".