ITPub博客

首页 > IT职业 > IT生活 > private void infoStatistics (SessionFactory sessionFactory) ;

private void infoStatistics (SessionFactory sessionFactory) ;

原创 IT生活 作者:tbase 时间:2007-09-06 16:27:47 0 删除 编辑

private void infoStatistics (SessionFactory sessionFactory) {
Statistics stats = sessionFactory.getStatistics();

// total statistics
stats.logSummary();
String[] clazz = stats.getEntityNames();

// entity statistics
if (clazz != null && clazz.length > 0) {
for (int i = 0; i < clazz.length; i++) {
EntityStatistics entityStats = stats
.getEntityStatistics(clazz[i]);

System.out.println(clazz[i]);
System.out.println("inserted : " + entityStats.getInsertCount());
System.out.println("updated : " + entityStats.getUpdateCount());
System.out.println("deleted : " + entityStats.getDeleteCount());
System.out.println("loaded : " + entityStats.getLoadCount());
}
}

String[] queries = stats.getQueries();

// queries statistics
if (queries != null && queries.length > 0) {
for (int i = 0; i < queries.length; i++) {
QueryStatistics queryStats = stats
.getQueryStatistics(queries[i]);
System.out.println(queries[i]);
System.out.println("ExecutionAvgTime : "
+ queryStats.getExecutionAvgTime());
System.out.println("ExecutionMinTime : "
+ queryStats.getExecutionMinTime());
System.out.println("ExecutionMaxTime : "
+ queryStats.getExecutionMaxTime());
System.out.println("ExecutionCount : "
+ queryStats.getExecutionCount());
System.out.println("ExecutionRowCount : "
+ queryStats.getExecutionRowCount());
}
}

// clear
stats.clear();

}

[@more@]

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/249132/viewspace-968246/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
  • 博文量
    28
  • 访问量
    156110