Skip to content

Instantly share code, notes, and snippets.

@sebersole
Created September 23, 2016 15:43
Show Gist options
  • Save sebersole/b13c11a9f7d55b84be6b4371e0259bc5 to your computer and use it in GitHub Desktop.
Save sebersole/b13c11a9f7d55b84be6b4371e0259bc5 to your computer and use it in GitHub Desktop.
/**
* Controls the base integer for binding JDBC-style ({@code ?}) ordinal
* parameters when the Hibernate SessionFactory is bootstrapped via the native
* bootstrapping API. JPA says that all non-named parameter binding is explicitly
* 1-based; so when bootstrapped via JPA, Hibernate always treats these as 1-based.
* <p/>
* Note that this affects only ordinal parameters. Positional
* parameters (e.g. {@code ?1}) explicitly define the binding position (1) in
* their declaration, whereas the binding position is implicit with ordinal
* parameters based on its ordinal position in the query. As of 6.0, support
* for this ordinal parameter declaration form has been removed from HQL and
* is now only valid for {@link org.hibernate.query.NativeQuery}s.
* <p/>
* Historically Hibernate followed JDBC conventions for ordinal parameter binding
* such that the implied positions were 0-based. This presents a mismatch between
* how to bind ordinal parameters based on how the SessionFactory was bootstrapped,
* which is not ideal. This setting then seeks to allow unifying how these are
* handled regardless of the bootstrap method. The expected value of this setting
* is an integer value of either 0 (the default) or 1. The default follows the legacy
* expectations and allows legacy Hibernate apps to continue to work. Setting this
* to 1 (one) allows all non-named parameter binding to be unified as 1-based.
*
* @since 6.0
*/
String NATIVE_QUERY_ORDINAL_PARAMETER_BASE = "hibernate.query.native.ordinal_parameter_base";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment