Hibernate Gives Connection Pool Error: Timeout waiting for idle object

Bug: Hibernate connection times out (after the maxWait duration set for the datasource), and gives error message in the log – “Timeout waiting for idle object”

Reason: Some operations were done using Hibernate session instead of Spring HibernateTemplate ; which were obtained using HibernateTemplate.getSession() function, and were not released by calling the HibernateTemplate.releaseSession();

Solution: Call this.releaseSession() from inside a spring-hibernateDao after the db operations. (ideally in a finally block).

Sreekumar Kj
Sreekumar (KJ) has been a hobby programmer from school days. Codemarvels is his personal blog from the year 2010, where he writes about technology, philosophy, society and a bit about physics. He now runs a conversational AI company - DheeYantra - focusing his efforts to help businesses improve operational efficiency using digital employees powered by AI.