views:

33

answers:

2

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

+1  A: 

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.

binil
+1  A: 

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

Scott