Skip to content

Commit 837e182

Browse files
committed
Merge pull request #353 from hazzik/NH-3707
NH-3707 - Port HHH-6845 - Avoid repeated invocations of ReflectHelper.OverridesEquals in proxy initializers
2 parents 8464829 + 7c1ac9b commit 837e182

File tree

4 files changed

+8
-9
lines changed

4 files changed

+8
-9
lines changed

src/NHibernate/Proxy/AbstractProxyFactory.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Reflection;
44
using NHibernate.Engine;
55
using NHibernate.Type;
6+
using NHibernate.Util;
67

78
namespace NHibernate.Proxy
89
{
@@ -17,6 +18,7 @@ public abstract class AbstractProxyFactory: IProxyFactory
1718
protected virtual MethodInfo GetIdentifierMethod { get; private set; }
1819
protected virtual MethodInfo SetIdentifierMethod { get; private set; }
1920
protected virtual IAbstractComponentType ComponentIdType { get; private set; }
21+
protected virtual bool OverridesEquals { get; set; }
2022

2123
protected bool IsClassProxy
2224
{
@@ -39,6 +41,7 @@ public virtual void PostInstantiate(string entityName, System.Type persistentCla
3941
GetIdentifierMethod = getIdentifierMethod;
4042
SetIdentifierMethod = setIdentifierMethod;
4143
ComponentIdType = componentIdType;
44+
OverridesEquals = ReflectHelper.OverridesEquals(persistentClass);
4245
}
4346

4447

src/NHibernate/Proxy/DefaultLazyInitializer.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,8 @@ public class DefaultLazyInitializer : BasicLazyInitializer, DynamicProxy.IInterc
1313
{
1414
public DefaultLazyInitializer(string entityName, System.Type persistentClass, object id, MethodInfo getIdentifierMethod,
1515
MethodInfo setIdentifierMethod, IAbstractComponentType componentIdType,
16-
ISessionImplementor session)
17-
: base(entityName, persistentClass, id, getIdentifierMethod, setIdentifierMethod, componentIdType, session) {}
18-
19-
#region Implementation of IInterceptor
16+
ISessionImplementor session, bool overridesEquals)
17+
: base(entityName, persistentClass, id, getIdentifierMethod, setIdentifierMethod, componentIdType, session, overridesEquals) {}
2018

2119
public object Intercept(InvocationInfo info)
2220
{
@@ -40,7 +38,5 @@ public object Intercept(InvocationInfo info)
4038

4139
return returnValue;
4240
}
43-
44-
#endregion
4541
}
4642
}

src/NHibernate/Proxy/DefaultProxyFactory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public override INHibernateProxy GetProxy(object id, ISessionImplementor session
1414
{
1515
try
1616
{
17-
var initializer = new DefaultLazyInitializer(EntityName, PersistentClass, id, GetIdentifierMethod, SetIdentifierMethod, ComponentIdType, session);
17+
var initializer = new DefaultLazyInitializer(EntityName, PersistentClass, id, GetIdentifierMethod, SetIdentifierMethod, ComponentIdType, session, OverridesEquals);
1818

1919
object proxyInstance = IsClassProxy
2020
? factory.CreateProxy(PersistentClass, initializer, Interfaces)

src/NHibernate/Proxy/Poco/BasicLazyInitializer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ public abstract class BasicLazyInitializer : AbstractLazyInitializer
2222

2323
protected internal BasicLazyInitializer(string entityName, System.Type persistentClass, object id,
2424
MethodInfo getIdentifierMethod, MethodInfo setIdentifierMethod,
25-
IAbstractComponentType componentIdType, ISessionImplementor session)
25+
IAbstractComponentType componentIdType, ISessionImplementor session, bool overridesEquals)
2626
: base(entityName, id, session)
2727
{
2828
this.persistentClass = persistentClass;
2929
this.getIdentifierMethod = getIdentifierMethod;
3030
this.setIdentifierMethod = setIdentifierMethod;
3131
this.componentIdType = componentIdType;
32-
overridesEquals = ReflectHelper.OverridesEquals(persistentClass);
32+
this.overridesEquals = overridesEquals;
3333
}
3434

3535
/// <summary>

0 commit comments

Comments
 (0)