From f5702548bbc238124fedbe0785cfcdd12b6bb960 Mon Sep 17 00:00:00 2001 From: Sanne Grinovero Date: Wed, 23 Nov 2011 17:19:03 +0000 Subject: [PATCH] HHH-6845 Avoid repeated invocations of ReflectHelper.overridesEquals in proxy initializers --- .../hibernate/proxy/pojo/BasicLazyInitializer.java | 5 +++-- .../pojo/javassist/JavassistLazyInitializer.java | 14 +++++++++----- .../pojo/javassist/JavassistProxyFactory.java | 6 +++++- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/proxy/pojo/BasicLazyInitializer.java b/hibernate-core/src/main/java/org/hibernate/proxy/pojo/BasicLazyInitializer.java index 3a5c1e64f4..8d1f20b489 100644 --- a/hibernate-core/src/main/java/org/hibernate/proxy/pojo/BasicLazyInitializer.java +++ b/hibernate-core/src/main/java/org/hibernate/proxy/pojo/BasicLazyInitializer.java @@ -57,13 +57,14 @@ public abstract class BasicLazyInitializer extends AbstractLazyInitializer { Method getIdentifierMethod, Method setIdentifierMethod, CompositeType componentIdType, - SessionImplementor session) { + SessionImplementor session, + boolean overridesEquals) { super(entityName, id, session); this.persistentClass = persistentClass; this.getIdentifierMethod = getIdentifierMethod; this.setIdentifierMethod = setIdentifierMethod; this.componentIdType = componentIdType; - overridesEquals = ReflectHelper.overridesEquals(persistentClass); + this.overridesEquals = overridesEquals; } protected abstract Object serializableProxy(); diff --git a/hibernate-core/src/main/java/org/hibernate/proxy/pojo/javassist/JavassistLazyInitializer.java b/hibernate-core/src/main/java/org/hibernate/proxy/pojo/javassist/JavassistLazyInitializer.java index 84cafc82c1..3e350dc451 100644 --- a/hibernate-core/src/main/java/org/hibernate/proxy/pojo/javassist/JavassistLazyInitializer.java +++ b/hibernate-core/src/main/java/org/hibernate/proxy/pojo/javassist/JavassistLazyInitializer.java @@ -69,8 +69,9 @@ public class JavassistLazyInitializer extends BasicLazyInitializer implements Me final Method getIdentifierMethod, final Method setIdentifierMethod, final CompositeType componentIdType, - final SessionImplementor session) { - super( entityName, persistentClass, id, getIdentifierMethod, setIdentifierMethod, componentIdType, session ); + final SessionImplementor session, + final boolean overridesEquals) { + super( entityName, persistentClass, id, getIdentifierMethod, setIdentifierMethod, componentIdType, session, overridesEquals ); this.interfaces = interfaces; } @@ -93,7 +94,8 @@ public class JavassistLazyInitializer extends BasicLazyInitializer implements Me getIdentifierMethod, setIdentifierMethod, componentIdType, - session + session, + ReflectHelper.overridesEquals(persistentClass) ); ProxyFactory factory = new ProxyFactory(); factory.setSuperclass( interfaces.length == 1 ? persistentClass : null ); @@ -120,7 +122,8 @@ public class JavassistLazyInitializer extends BasicLazyInitializer implements Me final Method setIdentifierMethod, final CompositeType componentIdType, final Serializable id, - final SessionImplementor session) throws HibernateException { + final SessionImplementor session, + final boolean classOverridesEquals) throws HibernateException { final JavassistLazyInitializer instance = new JavassistLazyInitializer( entityName, @@ -129,7 +132,8 @@ public class JavassistLazyInitializer extends BasicLazyInitializer implements Me getIdentifierMethod, setIdentifierMethod, componentIdType, - session + session, + classOverridesEquals ); final HibernateProxy proxy; diff --git a/hibernate-core/src/main/java/org/hibernate/proxy/pojo/javassist/JavassistProxyFactory.java b/hibernate-core/src/main/java/org/hibernate/proxy/pojo/javassist/JavassistProxyFactory.java index b4fd99aa0f..2f02812106 100644 --- a/hibernate-core/src/main/java/org/hibernate/proxy/pojo/javassist/JavassistProxyFactory.java +++ b/hibernate-core/src/main/java/org/hibernate/proxy/pojo/javassist/JavassistProxyFactory.java @@ -28,6 +28,7 @@ import java.util.Set; import org.hibernate.HibernateException; import org.hibernate.engine.spi.SessionImplementor; +import org.hibernate.internal.util.ReflectHelper; import org.hibernate.proxy.HibernateProxy; import org.hibernate.proxy.ProxyFactory; import org.hibernate.type.CompositeType; @@ -47,6 +48,7 @@ public class JavassistProxyFactory implements ProxyFactory, Serializable { private Method setIdentifierMethod; private CompositeType componentIdType; private Class factory; + private boolean overridesEquals; public void postInstantiate( final String entityName, @@ -62,6 +64,7 @@ public class JavassistProxyFactory implements ProxyFactory, Serializable { this.setIdentifierMethod = setIdentifierMethod; this.componentIdType = componentIdType; factory = JavassistLazyInitializer.getProxyFactory( persistentClass, this.interfaces ); + overridesEquals = ReflectHelper.overridesEquals(persistentClass); } public HibernateProxy getProxy( @@ -76,7 +79,8 @@ public class JavassistProxyFactory implements ProxyFactory, Serializable { setIdentifierMethod, componentIdType, id, - session + session, + overridesEquals ); }