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/trunk@18324 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
Gail Badner 2009-12-24 07:56:51 +00:00
parent e264d8e879
commit a7a9f79d1e
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;
}