hibernate显示查询执行时间 [英] hibernate show query execution time

查看:1041
本文介绍了hibernate显示查询执行时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



直到现在,我还没有找到安装hibernate或log4j来显示在hibernate中执行查询的时间。发现任何有趣的东西。



也许你们中的一些人可能会帮我解决这个问题吗? 有一个简单的方法(内置 hibernate )来实现它。它在 3.5.4中由 HHH-3659 修复。 3.6.0.Beta1



为此,请使用:




  • 登录包: org.hibernate.stat 至少在 INFO

  • 设置hibernate属性: hibernate.generate_statistics = true



然后将记录所有 SQL ,包括获取的行数和执行查询的时间。

此外,如果有兴趣,它还提供查询统计信息。要通过 JMX 公开它们并使用 JConsole 查看它们,可以使用 Hibernate JConsole插件,可在以下网址找到: http://hibernate-jcons.sourceforge.net/


I was looking for setup hibernate or log4j to show me, how long are executed queries in hibernate, which are invoked by hql.

Till now i didn't found anything interesting.

Maybe some of you might help me with this issue ?

解决方案

There is a simple way (built in hibernate) to achieve it. It was fixed by HHH-3659 in 3.5.4 and 3.6.0.Beta1.

To go for it, use:

  • logging on the package: org.hibernate.stat at least on INFO and
  • set hibernate property: hibernate.generate_statistics=true

Afterwards all the SQLs will be logged including the row count fetched and the time the query execution took.

Moreover if interested, it provides statistics on queries. To have them exposed via JMX and see them using JConsole, you can use Hibernate JConsole plugin, available on: http://hibernate-jcons.sourceforge.net/

这篇关于hibernate显示查询执行时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆