Results 1 to 2 of 2

Thread: unclosed connection, forgot to call close() on your session?

  1. #1
    Join Date
    Aug 2004
    Posts
    25

    Default unclosed connection, forgot to call close() on your session?

    I have some classes that extend HibernateDaoSupport. When I run certain types of queries using inner classes like this:

    Code:
        public List findBySomething(final Something aSomething)
        {
            return (List)getHibernateTemplate().execute(new HibernateCallback()
            {
                public Object doInHibernate(Session aSession)
                    throws HibernateException
                {
                    net.sf.hibernate.Query query = getHibernateTemplate().createQuery(
                        getSession(true),
                        "from Something s "
                            + "where s.something = :something ");
    
                    query.setString("something", aSomething);
    
                    return query.list();
                }
            });
        }
    I see output in the logs like this:

    Code:
    10 Feb 2005 10:09:31,118 [DEBUG] SessionFactoryUtils:311 - Opening Hibernate session
    10 Feb 2005 10:09:31,118 [DEBUG] SessionFactoryUtils:311 - Opening Hibernate session
    Hibernate: ... select statement redacted ...
    10 Feb 2005 10:09:31,448 [ WARN] SessionImpl:3435 - unclosed connection, forgot to call close() on your session?
    10 Feb 2005 10:09:31,458 [ WARN] SessionImpl:3435 - unclosed connection, forgot to call close() on your session?
    10 Feb 2005 10:09:31,458 [ WARN] SessionImpl:3435 - unclosed connection, forgot to call close() on your session?
    10 Feb 2005 10:09:31,458 [ WARN] SessionImpl:3435 - unclosed connection, forgot to call close() on your session?
    10 Feb 2005 10:09:31,458 [ WARN] SessionImpl:3435 - unclosed connection, forgot to call close() on your session?
    10 Feb 2005 10:09:31,458 [ WARN] SessionImpl:3435 - unclosed connection, forgot to call close() on your session?
    Any ideas on what could be the cause here? I'd post mapping files and so forth, but it's happening with several different mapped classes.

  2. #2
    Join Date
    Aug 2004
    Posts
    25

    Default

    Figured it out on my own.

    I should be calling aSession.createQuery() rather than getHibernateTemplate().createQuery() and creating the second session there.

Similar Threads

  1. OpenSessionInView and portlet support
    By garpinc2 in forum Web Flow
    Replies: 31
    Last Post: Apr 9th, 2010, 11:12 AM
  2. Hibernate Long Session Per Flow?
    By akw in forum Web Flow
    Replies: 21
    Last Post: Dec 12th, 2005, 08:06 PM
  3. Loosing my SecureContext
    By sklakken in forum Security
    Replies: 3
    Last Post: Jul 21st, 2005, 01:44 PM
  4. Unclosed Hibernate Connection
    By jvargas in forum Data
    Replies: 4
    Last Post: Mar 28th, 2005, 01:24 PM
  5. Replies: 3
    Last Post: Nov 19th, 2004, 07:16 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •