public class DataSourceQueryCountListener extends Object implements QueryExecutionListener
The default implementation uses the ThreadQueryCountHolder strategy, which stores
QueryCount objects in a thread-local variable. A QueryCount can be retrieved with
QueryCountHolder.get(String).
Alternatively, the SingleQueryCountHolder strategy can be used. It uses a single instance to store
QueryCount objects, which accumulate values across all threads until they are cleared.
In a web application, each HTTP request is handled by a single thread. Storing database access information in a thread-local variable provides metrics for each request. Using a single instance instead lets you retrieve accumulated totals since the application started.
QueryCount holds following data:
QueryCount,
QueryCountHolder,
QueryCountStrategy,
CommonsQueryCountLoggingServletFilter,
CommonsQueryCountLoggingRequestListener,
CommonsQueryCountLoggingHandlerInterceptorDEFAULT| Constructor and Description |
|---|
DataSourceQueryCountListener() |
| Modifier and Type | Method and Description |
|---|---|
void |
afterQuery(ExecutionInfo execInfo,
List<QueryInfo> queryInfoList) |
void |
beforeQuery(ExecutionInfo execInfo,
List<QueryInfo> queryInfoList) |
QueryCountStrategy |
getQueryCountStrategy() |
void |
setQueryCountStrategy(QueryCountStrategy queryCountStrategy) |
public void beforeQuery(ExecutionInfo execInfo, List<QueryInfo> queryInfoList)
beforeQuery in interface QueryExecutionListenerpublic void afterQuery(ExecutionInfo execInfo, List<QueryInfo> queryInfoList)
afterQuery in interface QueryExecutionListenerpublic QueryCountStrategy getQueryCountStrategy()
public void setQueryCountStrategy(QueryCountStrategy queryCountStrategy)
Copyright © 2026. All rights reserved.