Class HibernateObservingInterceptor

java.lang.Object
com.peterphi.std.guice.hibernate.module.logging.HibernateObservingInterceptor

public class HibernateObservingInterceptor extends Object
Uses hibernate's Interceptor class behind the scenes to allow observers to hook into events (N.B. but not alter them)
  • Constructor Details

    • HibernateObservingInterceptor

      public HibernateObservingInterceptor()
  • Method Details

    • getInterceptor

      public org.hibernate.Interceptor getInterceptor()
    • startSQLLogger

      public HibernateSQLLogger 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

      public HibernateSQLLogger startSQLLogger(String tracingOperationId)
      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

      public void addThreadLocalSQLAuditor(Consumer<String> observer)
      Add an observer to onPrepareStatement calls made by the current Thread until clearThreadLocalObservers() is called
      Parameters:
      observer -
    • removeThreadLocalSQLAuditor

      public void removeThreadLocalSQLAuditor(Consumer<String> observer)
      Remove a previously added observer for onPrepareStatement calls
      Parameters:
      observer -
    • clearThreadLocalObservers

      public void clearThreadLocalObservers()
      Clear any Thread Local observers