|
From: <ric...@us...> - 2010-08-29 17:17:45
|
Revision: 5169
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5169&view=rev
Author: ricbrown
Date: 2010-08-29 17:17:39 +0000 (Sun, 29 Aug 2010)
Log Message:
-----------
NHibernate.Test.Legacy.FumTest.CompositeIDQuery: corrected parameter positions for positional parameters (not working with Oracle)
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Engine/QueryParameters.cs
Modified: trunk/nhibernate/src/NHibernate/Engine/QueryParameters.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Engine/QueryParameters.cs 2010-08-25 12:23:28 UTC (rev 5168)
+++ trunk/nhibernate/src/NHibernate/Engine/QueryParameters.cs 2010-08-29 17:17:39 UTC (rev 5169)
@@ -105,11 +105,6 @@
_collectionKeys = collectionKeys;
_readOnly = readOnly;
_resultTransformer = transformer;
-
- if (_positionalParameterLocations == null)
- {
- CreatePositionalParameterLocations();
- }
}
public QueryParameters(IType[] positionalParameterTypes, object[] positionalParameterValues,
@@ -196,15 +191,15 @@
set { _lockModes = value; }
}
- private void CreatePositionalParameterLocations()
+ private void CreatePositionalParameterLocations(ISessionFactoryImplementor factory)
{
- if (_positionalParameterTypes != null)
+ _positionalParameterLocations = new int[_positionalParameterTypes.Length];
+ int location = 0;
+ for (int i = 0; i < _positionalParameterLocations.Length; i++)
{
- _positionalParameterLocations = new int[_positionalParameterTypes.Length];
- for (int i = 0; i < _positionalParameterLocations.Length; i++)
- {
- _positionalParameterLocations[i] = i;
- }
+ var span = _positionalParameterTypes[i].GetColumnSpan(factory);
+ _positionalParameterLocations[i] = location;
+ location += span;
}
}
@@ -460,6 +455,8 @@
int parameterIndex = 0;
int totalSpan = 0;
+ CreatePositionalParameterLocations(factory);
+
IList<Parameter> sqlParameters = FindParametersIn(sqlString);
for (int index = 0; index < PositionalParameterTypes.Length; index++)
@@ -470,7 +467,7 @@
int location = PositionalParameterLocations[index];
location = FindAdjustedParameterLocation(location);
int span = type.GetColumnSpan(factory);
- SetParameterLocation(sqlParameters, startParameterIndex + parameterIndex, location, span);
+ SetParameterLocation(sqlParameters, startParameterIndex + totalSpan, location, span);
totalSpan += span;
parameterIndex++;
@@ -483,7 +480,7 @@
int location = FilteredParameterLocations[index];
int span = type.GetColumnSpan(factory);
- SetParameterLocation(sqlParameters, startParameterIndex + parameterIndex, location, span);
+ SetParameterLocation(sqlParameters, startParameterIndex + totalSpan, location, span);
totalSpan += span;
parameterIndex++;
@@ -510,7 +507,7 @@
while ((location < sqlParameters.Count) && (sqlParameters[location].ParameterPosition != null))
location++;
- SetParameterLocation(sqlParameters, startParameterIndex + parameterIndex, location, span);
+ SetParameterLocation(sqlParameters, startParameterIndex + totalSpan, location, span);
}
totalSpan += span;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|