Java Persistence API (JPA) Extensions Reference for EclipseLink, Release 2.4
  Go To Table Of Contents
 Search
 PDFComments
Comments


jdbc.bind-parameters

Use eclipselink.jdbc.bind-parameters to specify if the query uses parameter binding (parameterized SQL).


Values

Table 4-13 describes this query hint's valid values.

Table 4-13 Valid Values for org.eclipse.persistence.config.HintValues

Value Description

TRUE

Bind all parameters.

FALSE

Do not bind all parameters.

PERSISTENCE_UNIT_DEFAULT

(Default) Use the parameter binding setting made in your EclipseLink session's database login, which is true by default.



Usage

By default, EclipseLink enables parameter binding and statement caching. This causes EclipseLink to use a prepared statement, binding all SQL parameters and caching the prepared statement. When you re-execute this query, you avoid the SQL preparation, which improves performance.

You can also configure parameter binding for the persistence unit in the persistence.xml file (when used in a Java SE environment).


Examples

Example 4-27 shows how to use this hint in a JPA query.

Example 4-27 Using bind-parameters in a JPA Query

import org.eclipse.persistence.config.HintValues;
 import org.eclipse.persistence.config.QueryHints;
 query.setHint(QueryHints.BIND_PARAMETERS, HintValues.TRUE);

Example 4-28 shows how to use this hint with the @QueryHint annotation.

Example 4-28 Using bind-parameters in a @QueryHint Annotation

import org.eclipse.persistence.config.HintValues;
 import org.eclipse.persistence.config.TargetDatabase;
 @QueryHint(name=QueryHints.BIND_PARAMETERS, value=HintValues.TRUE);

Example 4-29 shows how to configure parameter binding in the persistence unit persistence.xml file.

Example 4-29 Specifying Parameter Binding Persistence Unit Property

<property name="eclipselink.jdbc.bind-parameters" value="false"/>

Or by importing a property map:

import org.eclipse.persistence.config.PersistenceUnitProperties;
propertiesMap.put(PersistenceUnitProperties.NATIVE_SQL, "true");


See Also

For more information, see: