Hello all.

Back in June (23rd), Bill Holloway solved an 'illegal attempt to
associate a collection with two open sessions' hibernate exception by
using merge() after reattaching a detached object:
Re: T5 Creating new hibernate persistent entity via beaneditform
http://mail-archives.apache.org/mod_mbox/tapestry-users/200706.mbox/[EMAIL 
PROTECTED]

I wasn't quite convinced with this because that exception (though
often maligned!) is usually quite accurate.  Moreover, if there were
two sessions in play, using merge() would effectively _avoid_ the
issue by hydrating a new _copy_ of the (supposedly) detached object.

So i've been digging around (since, rather inevitably, i'm also seeing
this exception), and i don't see where the HibernateSessionManagerImpl
is actually _closing_ the thread local session...

What am i missing?  It seems unlikely we've been geting away with not
closing sessions.  Where might this be happening?

To test the theory i patched HibernateSessionManagerImpl to close the
session immediately after committing:
public void threadDidCleanup() {
    _transaction.commit();
    _session.close();
}

This gets rid of my 'illegal attempt...' exceptions!

Any insight appreciated.
Thanks,
lasitha.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to