HHH-4735 : Proxy can be associated with a new session when it is already connected to a different one (minor change for perf)

git-svn-id: https://svn.jboss.org/repos/hibernate/core/branches/Branch_3_3@18325 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
Gail Badner 2009-12-24 07:58:35 +00:00
parent 90f494116e
commit 87e0a7751e
1 changed files with 5 additions and 4 deletions

View File

@ -106,13 +106,14 @@ public abstract class AbstractLazyInitializer implements LazyInitializer {
*/
public final void setSession(SessionImplementor s) throws HibernateException {
if ( s != session ) {
if ( isConnectedToSession() ) {
// check for s == null first, since it is least expensive
if ( s == null ){
unsetSession();
}
else if ( isConnectedToSession() ) {
//TODO: perhaps this should be some other RuntimeException...
throw new HibernateException("illegally attempted to associate a proxy with two open Sessions");
}
else if ( s == null ){
unsetSession();
}
else {
session = s;
}