|
From: <fab...@us...> - 2009-06-16 02:40:38
|
Revision: 4482
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4482&view=rev
Author: fabiomaulo
Date: 2009-06-16 02:40:36 +0000 (Tue, 16 Jun 2009)
Log Message:
-----------
Minor refactoring + fix NH-1672
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Engine/Query/QueryPlanCache.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/EngineTest/QueryPlanCacheFixture.cs
Modified: trunk/nhibernate/src/NHibernate/Engine/Query/QueryPlanCache.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Engine/Query/QueryPlanCache.cs 2009-06-15 21:59:01 UTC (rev 4481)
+++ trunk/nhibernate/src/NHibernate/Engine/Query/QueryPlanCache.cs 2009-06-16 02:40:36 UTC (rev 4482)
@@ -33,7 +33,7 @@
public ParameterMetadata GetSQLParameterMetadata(string query)
{
- ParameterMetadata metadata = (ParameterMetadata)sqlParamMetadataCache[query];
+ var metadata = (ParameterMetadata)sqlParamMetadataCache[query];
if (metadata == null)
{
// for native-sql queries, the param metadata is determined outside
@@ -49,8 +49,8 @@
public HQLQueryPlan GetHQLQueryPlan(string queryString, bool shallow, IDictionary<string, IFilter> enabledFilters)
{
- HQLQueryPlanKey key = new HQLQueryPlanKey(queryString, shallow, enabledFilters);
- HQLQueryPlan plan = (HQLQueryPlan)planCache[key];
+ var key = new HQLQueryPlanKey(queryString, shallow, enabledFilters);
+ var plan = (HQLQueryPlan)planCache[key];
if (plan == null)
{
@@ -59,6 +59,7 @@
log.Debug("unable to locate HQL query plan in cache; generating (" + queryString + ")");
}
plan = new HQLQueryPlan(queryString, shallow, enabledFilters, factory);
+ planCache.Put(key, plan);
}
else
{
@@ -68,23 +69,23 @@
}
}
- planCache.Put(key, plan);
-
return plan;
}
public FilterQueryPlan GetFilterQueryPlan(string filterString, string collectionRole, bool shallow, IDictionary<string, IFilter> enabledFilters)
{
- FilterQueryPlanKey key = new FilterQueryPlanKey(filterString, collectionRole, shallow, enabledFilters);
- FilterQueryPlan plan = (FilterQueryPlan)planCache[key];
+ var key = new FilterQueryPlanKey(filterString, collectionRole, shallow, enabledFilters);
+ var plan = (FilterQueryPlan) planCache[key];
if (plan == null)
{
if (log.IsDebugEnabled)
{
- log.Debug("unable to locate collection-filter query plan in cache; generating (" + collectionRole + " : " + filterString + ")");
+ log.Debug("unable to locate collection-filter query plan in cache; generating (" + collectionRole + " : "
+ + filterString + ")");
}
plan = new FilterQueryPlan(filterString, collectionRole, shallow, enabledFilters, factory);
+ planCache.Put(key, plan);
}
else
{
@@ -94,14 +95,12 @@
}
}
- planCache.Put(key, plan);
-
return plan;
}
public NativeSQLQueryPlan GetNativeSQLQueryPlan(NativeSQLQuerySpecification spec)
{
- NativeSQLQueryPlan plan = (NativeSQLQueryPlan)planCache[spec];
+ var plan = (NativeSQLQueryPlan)planCache[spec];
if (plan == null)
{
@@ -110,6 +109,7 @@
log.Debug("unable to locate native-sql query plan in cache; generating (" + spec.QueryString + ")");
}
plan = new NativeSQLQueryPlan(spec, factory);
+ planCache.Put(spec, plan);
}
else
{
@@ -119,7 +119,6 @@
}
}
- planCache.Put(spec, plan);
return plan;
}
@@ -127,7 +126,7 @@
{
ParamLocationRecognizer recognizer = ParamLocationRecognizer.ParseLocations(sqlString);
- OrdinalParameterDescriptor[] ordinalDescriptors = new OrdinalParameterDescriptor[recognizer.OrdinalParameterLocationList.Count];
+ var ordinalDescriptors = new OrdinalParameterDescriptor[recognizer.OrdinalParameterLocationList.Count];
for (int i = 0; i < recognizer.OrdinalParameterLocationList.Count; i++)
{
int position = recognizer.OrdinalParameterLocationList[i];
@@ -177,12 +176,11 @@
public override bool Equals(object obj)
{
- if (this == obj)
- {
- return true;
- }
+ return this == obj || Equals(obj as HQLQueryPlanKey);
+ }
- HQLQueryPlanKey that = obj as HQLQueryPlanKey;
+ public bool Equals(HQLQueryPlanKey that)
+ {
if (that == null)
{
return false;
@@ -245,17 +243,15 @@
public override bool Equals(object obj)
{
- if (this == obj)
+ return this == obj || Equals(obj as FilterQueryPlanKey);
+ }
+
+ public bool Equals(FilterQueryPlanKey that)
+ {
+ if (that == null)
{
- return true;
- }
- if (obj == null || GetType() != obj.GetType())
- {
return false;
}
-
- FilterQueryPlanKey that = (FilterQueryPlanKey)obj;
-
if (shallow != that.shallow)
{
return false;
Added: trunk/nhibernate/src/NHibernate.Test/EngineTest/QueryPlanCacheFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/EngineTest/QueryPlanCacheFixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/EngineTest/QueryPlanCacheFixture.cs 2009-06-16 02:40:36 UTC (rev 4482)
@@ -0,0 +1,7 @@
+namespace NHibernate.Test.EngineTest
+{
+ public class QueryPlanCacheFixture
+ {
+
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-15 21:59:01 UTC (rev 4481)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-16 02:40:36 UTC (rev 4482)
@@ -148,6 +148,7 @@
<Compile Include="Criteria\ProjectionsTest.cs" />
<Compile Include="Criteria\Reptile.cs" />
<Compile Include="DriverTest\SqlClientDriverFixture.cs" />
+ <Compile Include="EngineTest\QueryPlanCacheFixture.cs" />
<Compile Include="ExpressionTest\RestrictionsFixture.cs" />
<Compile Include="Criteria\Student.cs" />
<Compile Include="Criteria\StudentDTO.cs" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|