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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddThreadLocalSQLAuditor(Consumer<String> observer) Add an observer toonPrepareStatementcalls made by the current Thread untilclearThreadLocalObservers()is calledvoidClear any Thread Local observersorg.hibernate.InterceptorvoidremoveThreadLocalSQLAuditor(Consumer<String> observer) Remove a previously added observer foronPrepareStatementcallsStart 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 toonPrepareStatementcalls made by the current Thread untilclearThreadLocalObservers()is called- Parameters:
observer-
-
removeThreadLocalSQLAuditor
Remove a previously added observer foronPrepareStatementcalls- Parameters:
observer-
-
clearThreadLocalObservers
public void clearThreadLocalObservers()Clear any Thread Local observers
-