Class SqlRecorder
- java.lang.Object
-
- com.querydsl.sql.SQLBaseListener
-
- com.evolveum.midpoint.repo.sqlbase.querydsl.SqlLogger
-
- com.evolveum.midpoint.repo.sqlbase.querydsl.SqlRecorder
-
- All Implemented Interfaces:
com.querydsl.sql.SQLDetailedListener
,com.querydsl.sql.SQLListener
public class SqlRecorder extends SqlLogger
Extension ofSqlLogger
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 bystartRecording()
andstopRecording()
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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SqlRecorder.QueryEntry
-
Field Summary
Fields Modifier and Type Field Description static Trace
LOGGER
-
Fields inherited from class com.evolveum.midpoint.repo.sqlbase.querydsl.SqlLogger
BYTE_ARRAY_PREVIEW_LEN
-
-
Constructor Summary
Constructors Constructor Description SqlRecorder(int queryBufferSize)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clearBuffer()
void
clearBufferAndStartRecording()
String
dumpQueryBuffer()
void
end(com.querydsl.sql.SQLListenerContext context)
End is the right phase common to both selects and insert/updates.Queue<SqlRecorder.QueryEntry>
getQueryBuffer()
Returns shallow copy of the query buffer in synchronized manner.boolean
isRecording()
void
startRecording()
void
stopRecording()
-
Methods inherited from class com.evolveum.midpoint.repo.sqlbase.querydsl.SqlLogger
start, valueToString
-
-
-
-
Field Detail
-
LOGGER
public static final Trace LOGGER
-
-
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.
-
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()
-
-