Class HibernateObservingInterceptor
java.lang.Object
com.peterphi.std.guice.hibernate.module.logging.HibernateObservingInterceptor
Uses hibernate's
Interceptor
class behind the scenes to allow observers to hook into events (N.B. but not alter them)-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addThreadLocalSQLAuditor
(Consumer<String> observer) Add an observer toonPrepareStatement
calls made by the current Thread untilclearThreadLocalObservers()
is calledvoid
Clear any Thread Local observersorg.hibernate.Interceptor
void
removeThreadLocalSQLAuditor
(Consumer<String> observer) Remove a previously added observer foronPrepareStatement
callsStart a new logger which records SQL Prepared Statements created by Hibernate in this Thread.startSQLLogger
(String tracingOperationId) Start a new logger which records SQL Prepared Statements created by Hibernate in this Thread.
-
Constructor Details
-
HibernateObservingInterceptor
public HibernateObservingInterceptor()
-
-
Method Details
-
getInterceptor
public org.hibernate.Interceptor getInterceptor() -
startSQLLogger
Start a new logger which records SQL Prepared Statements created by Hibernate in this Thread. Must be closed (or treated as autoclose)- Returns:
-
startSQLLogger
Start a new logger which records SQL Prepared Statements created by Hibernate in this Thread. Must be closed (or treated as autoclose)- Parameters:
tracingOperationId
- the tracing operation this sql logger should be associated with- Returns:
-
addThreadLocalSQLAuditor
Add an observer toonPrepareStatement
calls made by the current Thread untilclearThreadLocalObservers()
is called- Parameters:
observer
-
-
removeThreadLocalSQLAuditor
Remove a previously added observer foronPrepareStatement
calls- Parameters:
observer
-
-
clearThreadLocalObservers
public void clearThreadLocalObservers()Clear any Thread Local observers
-