本文整理汇总了Java中org.hibernate.stat.Statistics.getQueries方法的典型用法代码示例。如果您正苦于以下问题:Java Statistics.getQueries方法的具体用法?Java Statistics.getQueries怎么用?Java Statistics.getQueries使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.hibernate.stat.Statistics
的用法示例。
在下文中一共展示了Statistics.getQueries方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: asJson
import org.hibernate.stat.Statistics; //导入方法依赖的package包/类
@Override
public Map<String, Object> asJson() {
LinkedHashMap<String, Object> json = new LinkedHashMap<>();
Statistics statistics = sessionFactory.getStatistics();
if (!statistics.isStatisticsEnabled()){
return json;
}
json.put("EntityDeleteCount", statistics.getEntityDeleteCount());
json.put("EntityInsertCount", statistics.getEntityInsertCount());
json.put("EntityLoadCount", statistics.getEntityLoadCount());
json.put("EntityFetchCount", statistics.getEntityFetchCount());
json.put("EntityUpdateCount", statistics.getEntityUpdateCount());
json.put("QueryExecutionCount", statistics.getQueryExecutionCount());
json.put("QueryExecutionMaxTime", statistics.getQueryExecutionMaxTime());
json.put("QueryExecutionMaxTimeQueryString", statistics.getQueryExecutionMaxTimeQueryString());
json.put("QueryCacheHitCount", statistics.getQueryCacheHitCount());
json.put("QueryCacheMissCount", statistics.getQueryCacheMissCount());
json.put("QueryCachePutCount", statistics.getQueryCachePutCount());
json.put("FlushCount", statistics.getFlushCount());
json.put("ConnectCount", statistics.getConnectCount());
json.put("SecondLevelCacheHitCount", statistics.getSecondLevelCacheHitCount());
json.put("SecondLevelCacheMissCount", statistics.getSecondLevelCacheMissCount());
json.put("SecondLevelCachePutCount", statistics.getSecondLevelCachePutCount());
json.put("SessionCloseCount", statistics.getSessionCloseCount());
json.put("SessionOpenCount", statistics.getSessionOpenCount());
json.put("CollectionLoadCount", statistics.getCollectionLoadCount());
json.put("CollectionFetchCount", statistics.getCollectionFetchCount());
json.put("CollectionUpdateCount", statistics.getCollectionUpdateCount());
json.put("CollectionRemoveCount", statistics.getCollectionRemoveCount());
json.put("CollectionRecreateCount", statistics.getCollectionRecreateCount());
json.put("StartTime", statistics.getStartTime());
json.put("SecondLevelCacheRegionNames", statistics.getSecondLevelCacheRegionNames());
json.put("SuccessfulTransactionCount", statistics.getSuccessfulTransactionCount());
json.put("TransactionCount", statistics.getTransactionCount());
json.put("PrepareStatementCount", statistics.getPrepareStatementCount());
json.put("CloseStatementCount", statistics.getCloseStatementCount());
json.put("OptimisticFailureCount", statistics.getOptimisticFailureCount());
LinkedHashMap<String, Object> queryStats = new LinkedHashMap<>();
json.put("Queries", queryStats);
String[] queries = statistics.getQueries();
for (String query : queries) {
queryStats.put(query, statistics.getQueryStatistics(query));
}
LinkedHashMap<String, Object> entityStatistics = new LinkedHashMap<>();
json.put("EntityStatistics", entityStatistics);
String[] entityNames = statistics.getEntityNames();
for (String entityName : entityNames) {
entityStatistics.put(entityName, statistics.getEntityStatistics(entityName));
}
LinkedHashMap<String, Object> roleStatistics = new LinkedHashMap<>();
json.put("RoleStatistics", roleStatistics);
String[] roleNames = statistics.getCollectionRoleNames();
for (String roleName : roleNames) {
roleStatistics.put(roleName, statistics.getCollectionStatistics(roleName));
}
return json;
}