Author: gbadner
Date: 2009-12-24 02:56:51 -0500 (Thu, 24 Dec 2009)
New Revision: 18324
Modified:
core/trunk/core/src/main/java/org/hibernate/proxy/AbstractLazyInitializer.java
Log:
HHH-4735 : Proxy can be associated with a new session when it is already connected to a
different one (minor change for perf)
Modified: core/trunk/core/src/main/java/org/hibernate/proxy/AbstractLazyInitializer.java
===================================================================
---
core/trunk/core/src/main/java/org/hibernate/proxy/AbstractLazyInitializer.java 2009-12-24
03:14:34 UTC (rev 18323)
+++
core/trunk/core/src/main/java/org/hibernate/proxy/AbstractLazyInitializer.java 2009-12-24
07:56:51 UTC (rev 18324)
@@ -106,13 +106,14 @@
*/
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;
}
Show replies by date