代码之家  ›  专栏  ›  技术社区  ›  mkoryak

管理休眠会话

  •  2
  • mkoryak  · 技术社区  · 14 年前

    我正在尝试调试一个有性能问题的web应用程序。我打开了hibernate日志,看到了很多这样的情况:

    2010-10-28 10:58:00,423 DEBUG [org.hibernate.impl.SessionImpl] - opened session at timestamp: 5276786198212608
    2010-10-28 10:58:01,390 DEBUG [org.hibernate.impl.SessionImpl] - opened session at timestamp: 5276786202173440
    2010-10-28 10:58:01,418 DEBUG [org.hibernate.impl.SessionImpl] - opened session at timestamp: 5276786202288128
    2010-10-28 10:58:26,181 DEBUG [org.hibernate.impl.SessionImpl] - opened session at timestamp: 5276786303717376
    

    “非公开会议”

    我现在看到的是: http://static.springsource.org/spring/docs/2.5.x/reference/orm.html 但它没有任何东西能让我安心

    2 回复  |  直到 14 年前
        1
  •  1
  •   Scott    14 年前

    您如何访问会话?您正在使用spring事务注释吗?

    我们正在使用当前应用程序中的hibernate模板。。虽然这显然已经不再需要了。虽然我看到了其他hibernate初始化调试语句,但不知怎么的,我没有看到它作为调试出现。

    无论如何,您可能可以获得对会话工厂的引用并调用session factory.getStatistics().getsessionpencount()

    您可能必须调用setStatisticsEnabled(true)

    http://docs.jboss.org/hibernate/stable/core/api/org/hibernate/stat/Statistics.html

    根据binil的回答,还有一个关于在不同日志级别打开/关闭日志项的错误报告。 http://opensource.atlassian.com/projects/hibernate/browse/HHH-2425

        2
  •  3
  •   Binil Thomas    14 年前

    看着 source SessionImpl.java . 会话关闭时有相应的日志语句(请参见方法 public Connection close() throws HibernateException ),但登录到 TRACE 水平。我不熟悉slf4j,但来自 this piece of documentation 看起来像 DEBUG . 所以尝试增加日志记录的数量(可能 ALL ?) 并验证会话是否已关闭。