Skip to content

Commit f3013ad

Browse files
authoredNov 17, 2021
Force inline params in Criteria API
1 parent 4792944 commit f3013ad

File tree

1 file changed

+5
-4
lines changed
  • HibernateSpringBootForceInlineParams

1 file changed

+5
-4
lines changed
 

‎HibernateSpringBootForceInlineParams/README.md

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
**[How To Intercept The Generated SQL For Logging Or Altering](https://github.com/AnghelLeonard/Hibernate-SpringBoot/tree/master/HibernateSpringBootInterceptSql)**
1+
**[Force inline params in Criteria API](https://github.com/AnghelLeonard/Hibernate-SpringBoot/tree/master/HibernateSpringBootForceInlineParams)**
2+
3+
**NOTE** Use this with high precaution since you open the gate for SQL injections.
24

3-
**Description:** Sometimes we need to intercept the generated SQL that originates from Spring Data, `EntityManager`, Criteria API, `JdbcTemplate` and so on. This can be done as in this sample application. After interception, you can log, modify or even return a brand new SQL that will be executed in the end.
5+
**Description:** Sometimes we need to force inline params in Criteria API. By default, numeric parameters are inlined, but string parameters are not.
46

57
**Key points:**
6-
- define an implementation of Hibernate `StatementInspector` SPI
7-
- configure this SPI in `application.properties` via `spring.jpa.properties.hibernate.session_factory.statement_inspector`
8+
- configure in `application.properties` the setting `spring.jpa.properties.hibernate.criteria.literal_handling_mode` as `inline`
89

910
-----------------------------------------------------------------------------------------------------------------------
1011
<table>

0 commit comments

Comments
 (0)
Failed to load comments.