Skip to content

Commit f9ec55d

Browse files
committed
HHH-9576 - Use JDBC bind variables for handling JPA Criteria query numeric literals
Document the new setting in the Configurations chapter
1 parent 56947f2 commit f9ec55d

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

documentation/src/main/asciidoc/userguide/appendices/Annotations.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1284,7 +1284,7 @@ See the <<chapters/query/native/Native.adoc#sql-custom-crud-secondary-table-exam
12841284
The https://docs.jboss.org/hibernate/orm/{majorMinorVersion}/javadocs/org/hibernate/annotations/Tables.html[`@Tables`] annotation is used to group multiple <<annotations-hibernate-table>> annotations.
12851285

12861286
[[annotations-hibernate-target]]
1287-
==== `@Target`Se
1287+
==== `@Target`
12881288
The https://docs.jboss.org/hibernate/orm/{majorMinorVersion}/javadocs/org/hibernate/annotations/Target.html[`@Target`] annotation is used to specify an explicit target implementation when the current annotated association is using an interface type.
12891289

12901290
See the <<chapters/domain/basic_types.adoc#mapping-Target,`@Target` mapping>> section for more info.

documentation/src/main/asciidoc/userguide/appendices/Configurations.adoc

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -398,8 +398,21 @@ Can reference a
398398
`StatementInspector` implementation class name (fully-qualified class name).
399399

400400
`*hibernate.query.validate_parameters*` (e.g. `true` (default value) or `false`)::
401-
This configuration property can be used to disable parameters validation performed by `org.hibernate.query.Query#setParameter` when the the Session is bootstrapped via JPA
402-
`javax.persistence.EntityManagerFactory`
401+
This configuration property can be used to disable parameters validation performed by `org.hibernate.query.Query#setParameter` when the the Session is bootstrapped via JPA
402+
`javax.persistence.EntityManagerFactory`
403+
404+
`*hibernate.criteria.literal_handling_mode*` (e.g. `AUTO` (default value), `BIND` or `INLINE`)::
405+
By default, Criteria queries uses bind parameters for any literal that is not a numeric value.
406+
However, to increase the likelihood of JDBC statement caching, you might want to use bind parameters for numeric values too.
407+
+
408+
The `org.hibernate.query.criteria.LiteralHandlingMode#BIND` mode will use bind variables for any literal value.
409+
The `org.hibernate.query.criteria.LiteralHandlingMode#INLINE` mode will inline literal values as-is.
410+
+
411+
To prevent SQL injection, never use `org.hibernate.query.criteria.LiteralHandlingMode#INLINE` with String variables.
412+
Always use constants with the `org.hibernate.query.criteria.LiteralHandlingMode#INLINE` mode.
413+
+
414+
Valid options are defined by the `org.hibernate.query.criteria.LiteralHandlingMode` enum.
415+
The default value is `org.hibernate.query.criteria.LiteralHandlingMode#AUTO`.
403416

404417
==== Multi-table bulk HQL operations
405418

0 commit comments

Comments
 (0)