I have a Hibernate query that is configured to execute with Spring Data (the @Repository) annotation. I want to catch the query before it is submitted to the DB and when a speci
If you want to modify the query after the prepared statement, you can do it into an Hibernate Interceptor, and register it during Spring DB Configuration.
Your MyInterceptor either should implements Hibernate Interceptor.class or extends EmptyInterceptor.class. The method you are looking for is:
public String onPrepareStatement(String sql);
If you need something more, you could give a try with the Event Listeners, but I am not sure there is one for your case.
Here some documentation:
Hibernate 4.0 Interceptors and events How to integrate an Interceptor with Spring