Hibernate And Spring Modify Query Before Submitting To Db
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 specific
Solution 1:
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:
publicString 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 eventsHow to integrate an Interceptor with Spring
Post a Comment for "Hibernate And Spring Modify Query Before Submitting To Db"