管理休眠会话

发布于 2024-09-30 03:13:52 字数 775 浏览 0 评论 0原文

我正在尝试调试一个存在一些性能问题的网络应用程序。我打开了休眠日志记录,我看到了很多这样的内容:

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 但它没有任何东西能让我对日志感到安心

I am trying to debug a web app that is having some performance issues. i turned on hibernate logging and i am seeing a lot of this:

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

I am concerned that there are no logs about "closed session at"

i am currently look at this:
http://static.springsource.org/spring/docs/2.5.x/reference/orm.html
but it doesnt have anything that will give me a peace of mind about the logs

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

り繁华旳梦境 2024-10-07 03:13:52

查看 ,该消息似乎是从 SessionImpl.java 。会话关闭时有相应的日志语句(请参阅方法 public Connection close() throws HibernateException),但该日志记录在 TRACE 级别。我对 slf4j 不熟悉,但是来自 这篇文档 看起来 TRACE 的级别比 DEBUG 更精细。因此,请尝试增加日志记录量(也许增加到ALL?)并验证会话是否已关闭。

Looking at the source, the message seems to be logged from the constructor of SessionImpl.java. There is a corresponding log statement when sessions are closed (see the method public Connection close() throws HibernateException), but that is logged at TRACE level. I am not familiar with slf4j, but from this piece of documentation it looks like TRACE is at a finer level than DEBUG. So try increasing the amount of logging (maybe to ALL?) and verify if sessions are closed.

萌酱 2024-10-07 03:13:52

您如何访问会议?你使用的是spring事务注解吗?

我们在当前的应用程序中使用休眠模板..尽管这显然不再需要。虽然我确实看到了其他休眠初始化调试语句,但不知怎的,我没有看到它作为调试出现。

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

您可能必须调用 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

How are you accessing the sessions? Are you using the spring transaction annotation?

We're using the hibernate template in our current app.. though this is apparently no longer needed. I'm somehow not seeing that come out as debug, though I do see other hibernate initialization debug statements.

Anyhow, you can probably get a reference to the session factory and call sessionFactory.getStatistics().getSessionOpenCount()

You might have to call setStatisticsEnabled(true)

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

That would at least get you the number of open sessions to see if it is continually going up.

Per binil's answer, there is also a bug report about the opening/closing log entries at different log levels.
http://opensource.atlassian.com/projects/hibernate/browse/HHH-2425

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文