diff --git a/src/NHibernate/Engine/Query/QueryPlanCache.cs b/src/NHibernate/Engine/Query/QueryPlanCache.cs index 6a0c0b6a7ee..01849f96e77 100644 --- a/src/NHibernate/Engine/Query/QueryPlanCache.cs +++ b/src/NHibernate/Engine/Query/QueryPlanCache.cs @@ -196,20 +196,23 @@ private class HQLQueryPlanKey : IEquatable, IDeserializationCal // hashcode may vary among processes, they cannot be stored and have to be re-computed after deserialization [NonSerialized] private int? _hashCode; + + private readonly System.Type queryType; private readonly System.Type queryTypeDiscriminator; public HQLQueryPlanKey(string query, bool shallow, IDictionary enabledFilters) - : this(typeof(object), query, shallow, enabledFilters) + : this(typeof(object), typeof(object), query, shallow, enabledFilters) { } public HQLQueryPlanKey(IQueryExpression queryExpression, bool shallow, IDictionary enabledFilters) - : this(queryExpression.GetType(), queryExpression.Key, shallow, enabledFilters) + : this(queryExpression.Type, queryExpression.GetType(), queryExpression.Key, shallow, enabledFilters) { } - protected HQLQueryPlanKey(System.Type queryTypeDiscriminator, string query, bool shallow, IDictionary enabledFilters) + protected HQLQueryPlanKey(System.Type queryType, System.Type queryTypeDiscriminator, string query, bool shallow, IDictionary enabledFilters) { + this.queryType = queryType; this.queryTypeDiscriminator = queryTypeDiscriminator; this.query = query; this.shallow = shallow; @@ -255,6 +258,11 @@ public bool Equals(HQLQueryPlanKey that) return false; } + if (queryType != that.queryType) + { + return false; + } + if (queryTypeDiscriminator != that.queryTypeDiscriminator) { return false; @@ -285,6 +293,7 @@ private int GenerateHashCode() var hash = query.GetHashCode(); hash = 29 * hash + (shallow ? 1 : 0); hash = 29 * hash + CollectionHelper.GetHashCode(_filterNames); + hash = 29 * hash + queryType.GetHashCode(); hash = 29 * hash + queryTypeDiscriminator.GetHashCode(); return hash; }