Class SqlRecorder

  • All Implemented Interfaces:
    com.querydsl.sql.SQLDetailedListener, com.querydsl.sql.SQLListener

    public class SqlRecorder
    extends SqlLogger
    Extension of SqlLogger that includes buffer for queries which can be inspected later. Information to the buffer is added regardless of the logger level setting, but can be controlled by startRecording() and stopRecording() methods. Recording is off when the SQL recorder is created, only logging works. Maximum size of the buffer is provided in the constructor, information about older queries are discarded when the buffer is full. Query buffer contains SQL string and string for each parameter formatted for the logging. For instance, it contains just a preview of very long byte array, not the original value. Logs everything on debug, including parameters as they are formatted for the buffer anyway.
    • Field Detail

      • LOGGER

        public static final Trace LOGGER
    • Constructor Detail

      • SqlRecorder

        public SqlRecorder​(int queryBufferSize)
    • Method Detail

      • end

        public void end​(com.querydsl.sql.SQLListenerContext context)
        End is the right phase common to both selects and insert/updates. It's called after exceptions too.
        Specified by:
        end in interface com.querydsl.sql.SQLDetailedListener
        Overrides:
        end in class SqlLogger
      • getQueryBuffer

        public Queue<SqlRecorder.QueryEntry> getQueryBuffer()
        Returns shallow copy of the query buffer in synchronized manner.
      • dumpQueryBuffer

        public String dumpQueryBuffer()
      • clearBuffer

        public void clearBuffer()
      • clearBufferAndStartRecording

        public void clearBufferAndStartRecording()
      • startRecording

        public void startRecording()
      • stopRecording

        public void stopRecording()
      • isRecording

        public boolean isRecording()