HHH-6845 Avoid repeated invocations of ReflectHelper.overridesEquals in proxy initializers

This commit is contained in:
Sanne Grinovero 2011-11-23 17:19:03 +00:00
parent b4e65a0c79
commit f5702548bb
3 changed files with 17 additions and 8 deletions

View File

@ -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();

View File

@ -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;

View File

@ -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
);
}