• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

explicit releaseSession after getSession

Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was under the impression that one has to explicitly call releaseSession() after a getSession() or am I mistaken?

I am trying to diagnose a possible connection leak in our application. We have a DAO that extends HibernateDaoSupport. Some methods use the HibernateTemplate which I know handles everything automatically, other methods have calls to getSession() but in the method there is no corresponding call to releaseSession().

The Hibernate SessionFactory is injected to the DAO through Spring, a pretty standardized configuration. There is advice that is applied to this method as well which just has a propagation="REQUIRED" and nothing else.

The Hibernate session for the application UI is established via the OpenSessionInView pattern.

The strange thing is that our connection pool gets exhausted only under some scenarios i.e. when we are running some concurrent tasks performed by non-UI worker threads, just using the UI for any amount of time does not result in an increase in # of active pool connections. We have our connection pool set to max 30 connections, the app spawns a batch of 16 worker threads, after these are done the connections are not released, the next batch of 16 worker threads exhausts the pool as only 30-16=14 connections are available...so there is a leak somewhere and I think perhaps what I found above?
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Whenever the HibernateTemplate calls "getSession()" it eventually calls "releaseSession()". I'm pretty sure you have to follow the same pattern or you will see the kind of behavior you are seeing.
Did Steve tell you that? Fuh - Steve. Just look at this tiny ad:
the value of filler advertising in 2021
    Bookmark Topic Watch Topic
  • New Topic