Announcement Announcement Module
Collapse
No announcement yet.
unclosed connection, forgot to call close() on your session? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    Figured it out on my own.

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

    Comment

    Working...
    X