Skip to content

Latest commit

 

History

History

HibernateSpringBootInterceptSql

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

How To Intercept The Generated SQL For Logging Or Altering

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.

Key points:

  • define an implementation of Hibernate StatementInspector SPI
  • configure this SPI in application.properties via spring.jpa.properties.hibernate.session_factory.statement_inspector

If you need a deep dive into the performance recipes exposed in this repository then I am sure that you will love my book "Spring Boot Persistence Best Practices"If you need a hand of tips and illustrations of 100+ Java persistence performance issues then "Java Persistence Performance Illustrated Guide" is for you.