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


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


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

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

Value Description


Bind all parameters.


Do not bind all parameters.


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


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).


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: