You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
(248) |
May
(82) |
Jun
(90) |
Jul
(177) |
Aug
(253) |
Sep
(157) |
Oct
(151) |
Nov
(143) |
Dec
(278) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(152) |
Feb
(107) |
Mar
(177) |
Apr
(133) |
May
(259) |
Jun
(81) |
Jul
(119) |
Aug
(306) |
Sep
(416) |
Oct
(240) |
Nov
(329) |
Dec
(206) |
2006 |
Jan
(466) |
Feb
(382) |
Mar
(153) |
Apr
(162) |
May
(133) |
Jun
(21) |
Jul
(18) |
Aug
(37) |
Sep
(97) |
Oct
(114) |
Nov
(110) |
Dec
(28) |
2007 |
Jan
(74) |
Feb
(65) |
Mar
(49) |
Apr
(76) |
May
(43) |
Jun
(15) |
Jul
(68) |
Aug
(55) |
Sep
(63) |
Oct
(59) |
Nov
(70) |
Dec
(66) |
2008 |
Jan
(71) |
Feb
(60) |
Mar
(120) |
Apr
(31) |
May
(48) |
Jun
(81) |
Jul
(107) |
Aug
(51) |
Sep
(80) |
Oct
(83) |
Nov
(83) |
Dec
(79) |
2009 |
Jan
(83) |
Feb
(110) |
Mar
(97) |
Apr
(91) |
May
(291) |
Jun
(250) |
Jul
(197) |
Aug
(58) |
Sep
(54) |
Oct
(122) |
Nov
(68) |
Dec
(34) |
2010 |
Jan
(50) |
Feb
(17) |
Mar
(63) |
Apr
(61) |
May
(84) |
Jun
(81) |
Jul
(138) |
Aug
(144) |
Sep
(78) |
Oct
(26) |
Nov
(30) |
Dec
(61) |
2011 |
Jan
(33) |
Feb
(35) |
Mar
(166) |
Apr
(221) |
May
(109) |
Jun
(76) |
Jul
(27) |
Aug
(37) |
Sep
(1) |
Oct
(4) |
Nov
(2) |
Dec
(1) |
2012 |
Jan
|
Feb
|
Mar
(2) |
Apr
(2) |
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
(1) |
Oct
|
Nov
(1) |
Dec
|
2013 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
(1) |
Sep
(3) |
Oct
(2) |
Nov
|
Dec
(1) |
2014 |
Jan
(1) |
Feb
(1) |
Mar
(3) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <fab...@us...> - 2011-06-18 17:42:24
|
Revision: 5954 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5954&view=rev Author: fabiomaulo Date: 2011-06-18 17:42:18 +0000 (Sat, 18 Jun 2011) Log Message: ----------- Removed no more needed code Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Hql/Classic/QueryTranslator.cs Modified: trunk/nhibernate/src/NHibernate/Hql/Classic/QueryTranslator.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Classic/QueryTranslator.cs 2011-06-18 17:22:51 UTC (rev 5953) +++ trunk/nhibernate/src/NHibernate/Hql/Classic/QueryTranslator.cs 2011-06-18 17:42:18 UTC (rev 5954) @@ -1764,7 +1764,7 @@ public IParameterTranslations GetParameterTranslations() { - return new ParameterTranslations(this); + return new ParameterTranslationsImpl(CollectedParameterSpecifications); } public bool ContainsCollectionFetches @@ -1783,50 +1783,6 @@ #endregion - private class ParameterTranslations : IParameterTranslations - { - private readonly QueryTranslator queryTraslator; - - public ParameterTranslations(QueryTranslator queryTraslator) - { - this.queryTraslator = queryTraslator; - } - - #region IParameterTranslations Members - - public bool SupportsOrdinalParameterMetadata - { - get { return false; } - } - - public int OrdinalParameterCount - { - get { return 0; } - } - - public int GetOrdinalParameterSqlLocation(int ordinalPosition) - { - return 0; - } - - public IType GetOrdinalParameterExpectedType(int ordinalPosition) - { - return null; - } - - public IEnumerable<string> GetNamedParameterNames() - { - return queryTraslator.namedParameters.Keys; - } - - public IType GetNamedParameterExpectedType(string name) - { - return null; - } - - #endregion - } - public override string QueryIdentifier { get { return queryIdentifier; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2011-06-18 17:22:57
|
Revision: 5953 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5953&view=rev Author: fabiomaulo Date: 2011-06-18 17:22:51 +0000 (Sat, 18 Jun 2011) Log Message: ----------- Minor (reformatted) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Impl/ExpressionQueryImpl.cs Modified: trunk/nhibernate/src/NHibernate/Impl/ExpressionQueryImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/ExpressionQueryImpl.cs 2011-06-18 17:19:38 UTC (rev 5952) +++ trunk/nhibernate/src/NHibernate/Impl/ExpressionQueryImpl.cs 2011-06-18 17:22:51 UTC (rev 5953) @@ -5,273 +5,277 @@ using System.Text; using NHibernate.Engine; using NHibernate.Engine.Query; -using NHibernate.Engine.Query.Sql; using NHibernate.Hql.Ast.ANTLR; using NHibernate.Hql.Ast.ANTLR.Tree; using NHibernate.Hql.Ast.ANTLR.Util; -using NHibernate.Hql.Classic; using NHibernate.Type; using NHibernate.Util; namespace NHibernate.Impl { - class ExpressionQueryImpl : AbstractQueryImpl - { - private readonly Dictionary<string, LockMode> _lockModes = new Dictionary<string, LockMode>(2); + internal class ExpressionQueryImpl : AbstractQueryImpl + { + private readonly Dictionary<string, LockMode> _lockModes = new Dictionary<string, LockMode>(2); - public IQueryExpression QueryExpression { get; private set; } + public ExpressionQueryImpl(IQueryExpression queryExpression, ISessionImplementor session, ParameterMetadata parameterMetadata) + : base(queryExpression.Key, FlushMode.Unspecified, session, parameterMetadata) + { + QueryExpression = queryExpression; + } - public ExpressionQueryImpl(IQueryExpression queryExpression, ISessionImplementor session, ParameterMetadata parameterMetadata) - : base(queryExpression.Key, FlushMode.Unspecified, session, parameterMetadata) - { - QueryExpression = queryExpression; - } + public IQueryExpression QueryExpression { get; private set; } - public override IQuery SetLockMode(string alias, LockMode lockMode) - { - _lockModes[alias] = lockMode; - return this; - } + protected internal override IDictionary<string, LockMode> LockModes + { + get { return _lockModes; } + } - protected internal override IDictionary<string, LockMode> LockModes - { - get { return _lockModes; } - } + public override IQuery SetLockMode(string alias, LockMode lockMode) + { + _lockModes[alias] = lockMode; + return this; + } - public override int ExecuteUpdate() - { - throw new NotImplementedException(); - } + public override int ExecuteUpdate() + { + throw new NotImplementedException(); + } - public override IEnumerable Enumerable() - { - throw new NotImplementedException(); - } + public override IEnumerable Enumerable() + { + throw new NotImplementedException(); + } - public override IEnumerable<T> Enumerable<T>() - { - throw new NotImplementedException(); - } + public override IEnumerable<T> Enumerable<T>() + { + throw new NotImplementedException(); + } - public override IList List() - { - VerifyParameters(); - IDictionary<string, TypedValue> namedParams = NamedParams; - Before(); - try - { - return Session.List(ExpandParameters(namedParams), GetQueryParameters(namedParams)); - } - finally - { - After(); - } - } + public override IList List() + { + VerifyParameters(); + IDictionary<string, TypedValue> namedParams = NamedParams; + Before(); + try + { + return Session.List(ExpandParameters(namedParams), GetQueryParameters(namedParams)); + } + finally + { + After(); + } + } - /// <summary> - /// Warning: adds new parameters to the argument by side-effect, as well as mutating the query expression tree! - /// </summary> - protected IQueryExpression ExpandParameters(IDictionary<string, TypedValue> namedParamsCopy) - { + /// <summary> + /// Warning: adds new parameters to the argument by side-effect, as well as mutating the query expression tree! + /// </summary> + protected IQueryExpression ExpandParameters(IDictionary<string, TypedValue> namedParamsCopy) + { if (namedParameterLists.Count == 0) { // Short circuit straight out return QueryExpression; } - + // Build a map from single parameters to lists var map = new Dictionary<string, List<string>>(); - foreach (var me in namedParameterLists) + foreach (var me in namedParameterLists) { string name = me.Key; - var vals = (ICollection) me.Value.Value; - var type = me.Value.Type; - + var vals = (ICollection) me.Value.Value; + IType type = me.Value.Type; + if (vals.Count == 1) { // No expansion needed here - var iter = vals.GetEnumerator(); + IEnumerator iter = vals.GetEnumerator(); iter.MoveNext(); - namedParamsCopy[name] = new TypedValue(type, iter.Current, Session.EntityMode); + namedParamsCopy[name] = new TypedValue(type, iter.Current, Session.EntityMode); continue; } - + var aliases = new List<string>(); - var i = 0; - var isJpaPositionalParam = parameterMetadata.GetNamedParameterDescriptor(name).JpaStyle; + int i = 0; + bool isJpaPositionalParam = parameterMetadata.GetNamedParameterDescriptor(name).JpaStyle; - foreach (var obj in vals) - { - var alias = (isJpaPositionalParam ? 'x' + name : name + StringHelper.Underscore) + i++ + StringHelper.Underscore; - namedParamsCopy[alias] = new TypedValue(type, obj, Session.EntityMode); + foreach (object obj in vals) + { + string alias = (isJpaPositionalParam ? 'x' + name : name + StringHelper.Underscore) + i++ + StringHelper.Underscore; + namedParamsCopy[alias] = new TypedValue(type, obj, Session.EntityMode); aliases.Add(alias); - } - + } + map.Add(name, aliases); - } - var newTree = ParameterExpander.Expand(QueryExpression.Translate(Session.Factory), map); - var key = new StringBuilder(QueryExpression.Key); + IASTNode newTree = ParameterExpander.Expand(QueryExpression.Translate(Session.Factory), map); + var key = new StringBuilder(QueryExpression.Key); - map.Aggregate(key, (sb, kvp) => - { - sb.Append(' '); - sb.Append(kvp.Key); - sb.Append(':'); - kvp.Value.Aggregate(sb, (sb2, str) => sb2.Append(str)); - return sb; - }); + map.Aggregate(key, (sb, kvp) => + { + sb.Append(' '); + sb.Append(kvp.Key); + sb.Append(':'); + kvp.Value.Aggregate(sb, (sb2, str) => sb2.Append(str)); + return sb; + }); - return new ExpandedQueryExpression(QueryExpression, newTree, key.ToString()); - } + return new ExpandedQueryExpression(QueryExpression, newTree, key.ToString()); + } - public override void List(IList results) - { - throw new NotImplementedException(); - } + public override void List(IList results) + { + throw new NotImplementedException(); + } - public override IList<T> List<T>() - { - throw new NotImplementedException(); - } - } + public override IList<T> List<T>() + { + throw new NotImplementedException(); + } + } - internal class ExpandedQueryExpression : IQueryExpression - { - private readonly IASTNode _tree; + internal class ExpandedQueryExpression : IQueryExpression + { + private readonly IASTNode _tree; - public ExpandedQueryExpression(IQueryExpression queryExpression, IASTNode tree, string key) - { - _tree = tree; - Key = key; - Type = queryExpression.Type; - ParameterDescriptors = queryExpression.ParameterDescriptors; - } + public ExpandedQueryExpression(IQueryExpression queryExpression, IASTNode tree, string key) + { + _tree = tree; + Key = key; + Type = queryExpression.Type; + ParameterDescriptors = queryExpression.ParameterDescriptors; + } - public IASTNode Translate(ISessionFactoryImplementor sessionFactory) - { - return _tree; - } + #region IQueryExpression Members - public string Key { get; private set; } + public IASTNode Translate(ISessionFactoryImplementor sessionFactory) + { + return _tree; + } - public System.Type Type { get; private set; } + public string Key { get; private set; } - public IList<NamedParameterDescriptor> ParameterDescriptors { get; private set; } - } + public System.Type Type { get; private set; } - internal class ParameterExpander + public IList<NamedParameterDescriptor> ParameterDescriptors { get; private set; } + + #endregion + } + + internal class ParameterExpander { - private readonly IASTNode _tree; - private readonly Dictionary<string, List<string>> _map; + private readonly Dictionary<string, List<string>> _map; + private readonly IASTNode _tree; - private ParameterExpander(IASTNode tree, Dictionary<string, List<string>> map) - { - _tree = tree; - _map = map; - } + private ParameterExpander(IASTNode tree, Dictionary<string, List<string>> map) + { + _tree = tree; + _map = map; + } - public static IASTNode Expand(IASTNode tree, Dictionary<string, List<string>> map) - { - var expander = new ParameterExpander(tree, map); + public static IASTNode Expand(IASTNode tree, Dictionary<string, List<string>> map) + { + var expander = new ParameterExpander(tree, map); - return expander.Expand(); - } + return expander.Expand(); + } - private IASTNode Expand() - { - var parameters = ParameterDetector.LocateParameters(_tree, new HashSet<string>(_map.Keys)); - var nodeMapping = new Dictionary<IASTNode, IEnumerable<IASTNode>>(); + private IASTNode Expand() + { + IList<IASTNode> parameters = ParameterDetector.LocateParameters(_tree, new HashSet<string>(_map.Keys)); + var nodeMapping = new Dictionary<IASTNode, IEnumerable<IASTNode>>(); - foreach (var param in parameters) - { - var paramName = param.GetChild(0); - var aliases = _map[paramName.Text]; - var astAliases = new List<IASTNode>(); + foreach (IASTNode param in parameters) + { + IASTNode paramName = param.GetChild(0); + List<string> aliases = _map[paramName.Text]; + var astAliases = new List<IASTNode>(); - foreach (var alias in aliases) - { - var astAlias = param.DupNode(); - var astAliasName = paramName.DupNode(); - astAliasName.Text = alias; - astAlias.AddChild(astAliasName); + foreach (string alias in aliases) + { + IASTNode astAlias = param.DupNode(); + IASTNode astAliasName = paramName.DupNode(); + astAliasName.Text = alias; + astAlias.AddChild(astAliasName); - astAliases.Add(astAlias); - } + astAliases.Add(astAlias); + } - nodeMapping.Add(param, astAliases); - } + nodeMapping.Add(param, astAliases); + } - return DuplicateTree(_tree, nodeMapping); - } + return DuplicateTree(_tree, nodeMapping); + } - private static IASTNode DuplicateTree(IASTNode ast, IDictionary<IASTNode, IEnumerable<IASTNode>> nodeMapping) - { - var thisNode = ast.DupNode(); + private static IASTNode DuplicateTree(IASTNode ast, IDictionary<IASTNode, IEnumerable<IASTNode>> nodeMapping) + { + IASTNode thisNode = ast.DupNode(); - foreach (var child in ast) - { - IEnumerable<IASTNode> candidate; + foreach (IASTNode child in ast) + { + IEnumerable<IASTNode> candidate; - if (nodeMapping.TryGetValue(child, out candidate)) - { - foreach (var replacement in candidate) - { - thisNode.AddChild(replacement); - } - } - else - { - thisNode.AddChild(DuplicateTree(child, nodeMapping)); - } - } + if (nodeMapping.TryGetValue(child, out candidate)) + { + foreach (IASTNode replacement in candidate) + { + thisNode.AddChild(replacement); + } + } + else + { + thisNode.AddChild(DuplicateTree(child, nodeMapping)); + } + } - return thisNode; - } - } + return thisNode; + } + } - internal class ParameterDetector : IVisitationStrategy - { - private readonly IASTNode _tree; - private readonly HashSet<string> _parameterNames; - private readonly List<IASTNode> _nodes; + internal class ParameterDetector : IVisitationStrategy + { + private readonly List<IASTNode> _nodes; + private readonly HashSet<string> _parameterNames; + private readonly IASTNode _tree; - private ParameterDetector(IASTNode tree, HashSet<string> parameterNames) - { - _tree = tree; - _parameterNames = parameterNames; - _nodes = new List<IASTNode>(); - } + private ParameterDetector(IASTNode tree, HashSet<string> parameterNames) + { + _tree = tree; + _parameterNames = parameterNames; + _nodes = new List<IASTNode>(); + } - public static IList<IASTNode> LocateParameters(IASTNode tree, HashSet<string> parameterNames) - { - var detector = new ParameterDetector(tree, parameterNames); + #region IVisitationStrategy Members - return detector.LocateParameters(); - } + public void Visit(IASTNode node) + { + if ((node.Type == HqlSqlWalker.PARAM) || (node.Type == HqlSqlWalker.COLON)) + { + string name = node.GetChild(0).Text; - private IList<IASTNode> LocateParameters() - { - var nodeTraverser = new NodeTraverser(this); - nodeTraverser.TraverseDepthFirst(_tree); + if (_parameterNames.Contains(name)) + { + _nodes.Add(node); + } + } + } - return _nodes; - } + #endregion - public void Visit(IASTNode node) - { - if ((node.Type == HqlSqlWalker.PARAM) || (node.Type == HqlSqlWalker.COLON)) - { - var name = node.GetChild(0).Text; + public static IList<IASTNode> LocateParameters(IASTNode tree, HashSet<string> parameterNames) + { + var detector = new ParameterDetector(tree, parameterNames); - if (_parameterNames.Contains(name)) - { - _nodes.Add(node); - } - } - } + return detector.LocateParameters(); + } - } + private IList<IASTNode> LocateParameters() + { + var nodeTraverser = new NodeTraverser(this); + nodeTraverser.TraverseDepthFirst(_tree); + + return _nodes; + } + } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2011-06-18 17:19:44
|
Revision: 5952 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5952&view=rev Author: fabiomaulo Date: 2011-06-18 17:19:38 +0000 (Sat, 18 Jun 2011) Log Message: ----------- Removed no more needed code Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Impl/MultiQueryImpl.cs Modified: trunk/nhibernate/src/NHibernate/Impl/MultiQueryImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/MultiQueryImpl.cs 2011-06-18 15:57:58 UTC (rev 5951) +++ trunk/nhibernate/src/NHibernate/Impl/MultiQueryImpl.cs 2011-06-18 17:19:38 UTC (rev 5952) @@ -1,9 +1,7 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Data.Common; using System.Diagnostics; -using System.Linq; using Iesi.Collections; using Iesi.Collections.Generic; using NHibernate.Cache; @@ -664,22 +662,6 @@ } } - private static QueryParameters GetFilteredQueryParameters(QueryParameters queryParameters, ITranslator translator) - { - QueryParameters filteredQueryParameters = queryParameters; - Dictionary<string, TypedValue> namedParameters = new Dictionary<string, TypedValue>(queryParameters.NamedParameters); - filteredQueryParameters.NamedParameters.Clear(); - foreach (string paramName in translator.GetNamedParameterNames()) - { - TypedValue v; - if (namedParameters.TryGetValue(paramName, out v)) - { - filteredQueryParameters.NamedParameters.Add(paramName, v); - } - } - return filteredQueryParameters; - } - public object GetResult(string key) { if (queryResults == null) @@ -818,7 +800,6 @@ IType[] ReturnTypes { get; } string[] ReturnAliases { get; } ICollection<string> QuerySpaces { get; } - IEnumerable<string> GetNamedParameterNames(); } private class HqlTranslatorWrapper : ITranslator @@ -849,11 +830,6 @@ { get { return innerTranslator.ReturnAliases; } } - - public IEnumerable<string> GetNamedParameterNames() - { - return innerTranslator.GetParameterTranslations().GetNamedParameterNames(); - } } private class SqlTranslator : ITranslator @@ -887,11 +863,6 @@ { get { return loader.ReturnAliases; } } - - public IEnumerable<string> GetNamedParameterNames() - { - return loader.NamedParameters; - } } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jul...@us...> - 2011-06-18 15:58:06
|
Revision: 5951 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5951&view=rev Author: julian-maughan Date: 2011-06-18 15:57:58 +0000 (Sat, 18 Jun 2011) Log Message: ----------- Corrected a few spelling, grammatical and typographical mistakes in the ByCode namespace Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Mapping/ByCode/AbstractExplicitlyDeclaredModel.cs trunk/nhibernate/src/NHibernate/Mapping/ByCode/ConventionModelMapper.cs trunk/nhibernate/src/NHibernate/Mapping/ByCode/FakeModelExplicitDeclarationsHolder.cs trunk/nhibernate/src/NHibernate/Mapping/ByCode/IClassMapper.cs trunk/nhibernate/src/NHibernate/Mapping/ByCode/IKeyMapper.cs trunk/nhibernate/src/NHibernate/Mapping/ByCode/IManyToManyMapper.cs trunk/nhibernate/src/NHibernate/Mapping/ByCode/IPlainPropertyContainerMapper.cs trunk/nhibernate/src/NHibernate/Mapping/ByCode/IPropertyContainerMapper.cs trunk/nhibernate/src/NHibernate/Mapping/ByCode/ISubclassMapper.cs trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/ClassMapper.cs trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/ClassCustomizer.cs trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/CollectionKeyCustomizer.cs trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/JoinCustomizer.cs trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/JoinKeyCustomizer.cs trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/JoinedSubclassKeyCustomizer.cs trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/ManyToManyCustomizer.cs trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/NaturalIdCustomizer.cs trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/PropertyContainerCustomizer.cs trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/SubclassCustomizer.cs trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/KeyMapper.cs trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/ManyToManyMapper.cs trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/SubclassMapper.cs trunk/nhibernate/src/NHibernate/Mapping/ByCode/ModelMapper.cs trunk/nhibernate/src/NHibernate/Mapping/ByCode/PropertyToField.cs trunk/nhibernate/src/NHibernate/Mapping/ByCode/SimpleModelInspector.cs trunk/nhibernate/src/NHibernate/Mapping/ByCode/TypeExtensions.cs Modified: trunk/nhibernate/src/NHibernate/Mapping/ByCode/AbstractExplicitlyDeclaredModel.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Mapping/ByCode/AbstractExplicitlyDeclaredModel.cs 2011-06-18 13:38:07 UTC (rev 5950) +++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/AbstractExplicitlyDeclaredModel.cs 2011-06-18 15:57:58 UTC (rev 5951) @@ -173,10 +173,10 @@ public IEnumerable<string> GetSplitGroupsFor(System.Type type) { - HashSet<string> splitsGroupsIds; - if (typeSplitGroups.TryGetValue(type, out splitsGroupsIds)) + HashSet<string> splitGroupIds; + if (typeSplitGroups.TryGetValue(type, out splitGroupIds)) { - return splitsGroupsIds; + return splitGroupIds; } return Enumerable.Empty<string>(); } @@ -222,7 +222,7 @@ { if(!rootEntityMustExists) { - delayedRootEntityRegistrations.Enqueue(() => System.Array.ForEach(GetRootEntitentitiesOf(type).ToArray(), root=> tablePerClassEntities.Add(root))); + delayedRootEntityRegistrations.Enqueue(() => System.Array.ForEach(GetRootEntitiesOf(type).ToArray(), root=> tablePerClassEntities.Add(root))); EnlistTypeRegistration(type, t => AddAsTablePerClassEntity(t, true)); return; } @@ -257,7 +257,7 @@ { if (!rootEntityMustExists) { - delayedRootEntityRegistrations.Enqueue(() => System.Array.ForEach(GetRootEntitentitiesOf(type).ToArray(), root => tablePerClassHierarchyEntities.Add(root))); + delayedRootEntityRegistrations.Enqueue(() => System.Array.ForEach(GetRootEntitiesOf(type).ToArray(), root => tablePerClassHierarchyEntities.Add(root))); EnlistTypeRegistration(type, t => AddAsTablePerClassHierarchyEntity(t, true)); return; } @@ -293,7 +293,7 @@ { if (!rootEntityMustExists) { - delayedRootEntityRegistrations.Enqueue(() => System.Array.ForEach(GetRootEntitentitiesOf(type).ToArray(), root => tablePerConcreteClassEntities.Add(root))); + delayedRootEntityRegistrations.Enqueue(() => System.Array.ForEach(GetRootEntitiesOf(type).ToArray(), root => tablePerConcreteClassEntities.Add(root))); EnlistTypeRegistration(type, t => AddAsTablePerConcreteClassEntity(t, true)); return; } @@ -477,7 +477,7 @@ protected System.Type GetSingleRootEntityOrNull(System.Type entityType) { - var rootTypes = GetRootEntitentitiesOf(entityType).ToList(); + var rootTypes = GetRootEntitiesOf(entityType).ToList(); if(rootTypes.Count > 1) { var sb = new StringBuilder(1024); @@ -494,7 +494,7 @@ return rootTypes.SingleOrDefault(IsRootEntity); } - protected IEnumerable<System.Type> GetRootEntitentitiesOf(System.Type entityType) + protected IEnumerable<System.Type> GetRootEntitiesOf(System.Type entityType) { if (entityType == null) { Modified: trunk/nhibernate/src/NHibernate/Mapping/ByCode/ConventionModelMapper.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Mapping/ByCode/ConventionModelMapper.cs 2011-06-18 13:38:07 UTC (rev 5950) +++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/ConventionModelMapper.cs 2011-06-18 15:57:58 UTC (rev 5951) @@ -57,7 +57,7 @@ BeforeMapAny += MemberReadOnlyAccessor; } - protected virtual void ComponentParentToFieldAccessor(IModelInspector modelinspector, PropertyPath member, IComponentAttributesMapper componentMapper) + protected virtual void ComponentParentToFieldAccessor(IModelInspector modelInspector, PropertyPath member, IComponentAttributesMapper componentMapper) { System.Type componentType = member.LocalMember.GetPropertyOrFieldType(); IEnumerable<MemberInfo> persistentProperties = @@ -70,7 +70,7 @@ } } - protected virtual void ComponentParentNoSetterToField(IModelInspector modelinspector, PropertyPath member, IComponentAttributesMapper componentMapper) + protected virtual void ComponentParentNoSetterToField(IModelInspector modelInspector, PropertyPath member, IComponentAttributesMapper componentMapper) { System.Type componentType = member.LocalMember.GetPropertyOrFieldType(); IEnumerable<MemberInfo> persistentProperties = Modified: trunk/nhibernate/src/NHibernate/Mapping/ByCode/FakeModelExplicitDeclarationsHolder.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Mapping/ByCode/FakeModelExplicitDeclarationsHolder.cs 2011-06-18 13:38:07 UTC (rev 5950) +++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/FakeModelExplicitDeclarationsHolder.cs 2011-06-18 15:57:58 UTC (rev 5951) @@ -198,11 +198,13 @@ public void AddAsManyToManyRelation(MemberInfo member) {} public void AddAsOneToManyRelation(MemberInfo member) {} + public void AddAsManyToAnyRelation(MemberInfo member) {} public void AddAsAny(MemberInfo member) {} public void AddAsPoid(MemberInfo member) {} + public void AddAsPartOfComposedId(MemberInfo member) {} public void AddAsVersionProperty(MemberInfo member) {} @@ -222,9 +224,13 @@ public void AddAsMap(MemberInfo member) {} public void AddAsProperty(MemberInfo member) {} - public void AddAsPersistentMember(MemberInfo member){} + + public void AddAsPersistentMember(MemberInfo member) {} + public void AddAsPropertySplit(SplitDefinition definition) {} + public void AddAsDynamicComponent(MemberInfo member, System.Type componentTemplate) {} + #endregion } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Mapping/ByCode/IClassMapper.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Mapping/ByCode/IClassMapper.cs 2011-06-18 13:38:07 UTC (rev 5950) +++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/IClassMapper.cs 2011-06-18 15:57:58 UTC (rev 5951) @@ -32,20 +32,20 @@ /// Using the Join, it is possible to split properties of one class to several tables, when there's a 1-to-1 relationship between the table /// </summary> /// <param name="splitGroupId">The split-group identifier. By default it is assigned to the join-table-name</param> - /// <param name="splittedMapping">The lambda to map the join.</param> - void Join(string splitGroupId, Action<IJoinMapper> splittedMapping); + /// <param name="splitMapping">The lambda to map the join.</param> + void Join(string splitGroupId, Action<IJoinMapper> splitMapping); } public interface IClassAttributesMapper<TEntity> : IEntityAttributesMapper, IEntitySqlsMapper where TEntity : class { void Id<TProperty>(Expression<Func<TEntity, TProperty>> idProperty); void Id<TProperty>(Expression<Func<TEntity, TProperty>> idProperty, Action<IIdMapper> idMapper); - void Id(string notVidiblePropertyOrFieldName, Action<IIdMapper> idMapper); + void Id(string notVisiblePropertyOrFieldName, Action<IIdMapper> idMapper); void ComponentAsId<TComponent>(Expression<Func<TEntity, TComponent>> idProperty) where TComponent : class; void ComponentAsId<TComponent>(Expression<Func<TEntity, TComponent>> idProperty, Action<IComponentAsIdMapper<TComponent>> idMapper) where TComponent : class; - void ComponentAsId<TComponent>(string notVidiblePropertyOrFieldName) where TComponent : class; - void ComponentAsId<TComponent>(string notVidiblePropertyOrFieldName, Action<IComponentAsIdMapper<TComponent>> idMapper) where TComponent : class; + void ComponentAsId<TComponent>(string notVisiblePropertyOrFieldName) where TComponent : class; + void ComponentAsId<TComponent>(string notVisiblePropertyOrFieldName, Action<IComponentAsIdMapper<TComponent>> idMapper) where TComponent : class; void ComposedId(Action<IComposedIdMapper<TEntity>> idPropertiesMapping); @@ -56,7 +56,7 @@ void Schema(string schemaName); void Mutable(bool isMutable); void Version<TProperty>(Expression<Func<TEntity, TProperty>> versionProperty, Action<IVersionMapper> versionMapping); - void Version(string notVidiblePropertyOrFieldName, Action<IVersionMapper> versionMapping); + void Version(string notVisiblePropertyOrFieldName, Action<IVersionMapper> versionMapping); void NaturalId(Action<IBasePlainPropertyContainerMapper<TEntity>> naturalIdPropertiesMapping, Action<INaturalIdAttributesMapper> naturalIdMapping); void NaturalId(Action<IBasePlainPropertyContainerMapper<TEntity>> naturalIdPropertiesMapping); void Cache(Action<ICacheMapper> cacheMapping); @@ -67,6 +67,6 @@ public interface IClassMapper<TEntity> : IClassAttributesMapper<TEntity>, IPropertyContainerMapper<TEntity> where TEntity : class { - void Join(string splitGroupId, Action<IJoinMapper<TEntity>> splittedMapping); + void Join(string splitGroupId, Action<IJoinMapper<TEntity>> splitMapping); } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Mapping/ByCode/IKeyMapper.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Mapping/ByCode/IKeyMapper.cs 2011-06-18 13:38:07 UTC (rev 5950) +++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/IKeyMapper.cs 2011-06-18 15:57:58 UTC (rev 5951) @@ -19,14 +19,14 @@ void Unique(bool unique); /// <summary> - /// Set the Foreing-Key name + /// Set the Foreign-Key name /// </summary> - /// <param name="foreingKeyName">The name of the Foreing-Key</param> + /// <param name="foreignKeyName">The name of the Foreign-Key</param> /// <remarks> - /// Where the <paramref name="foreingKeyName"/> is "none" or <see cref="string.Empty"/> or all white-spaces the FK won't be created. + /// Where the <paramref name="foreignKeyName"/> is "none" or <see cref="string.Empty"/> or all white-spaces the FK won't be created. /// Use null to reset the default NHibernate's behavior. /// </remarks> - void ForeignKey(string foreingKeyName); + void ForeignKey(string foreignKeyName); } public interface IKeyMapper<TEntity> : IColumnsMapper where TEntity : class @@ -34,7 +34,7 @@ void OnDelete(OnDeleteAction deleteAction); void PropertyRef<TProperty>(Expression<Func<TEntity, TProperty>> propertyGetter); void Update(bool consideredInUpdateQuery); - void ForeignKey(string foreingKeyName); + void ForeignKey(string foreignKeyName); void NotNullable(bool notnull); void Unique(bool unique); } Modified: trunk/nhibernate/src/NHibernate/Mapping/ByCode/IManyToManyMapper.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Mapping/ByCode/IManyToManyMapper.cs 2011-06-18 13:38:07 UTC (rev 5950) +++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/IManyToManyMapper.cs 2011-06-18 15:57:58 UTC (rev 5951) @@ -7,6 +7,6 @@ void NotFound(NotFoundMode mode); void Formula(string formula); void Lazy(LazyRelation lazyRelation); - void ForeignKey(string foreingKeyName); + void ForeignKey(string foreignKeyName); } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Mapping/ByCode/IPlainPropertyContainerMapper.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Mapping/ByCode/IPlainPropertyContainerMapper.cs 2011-06-18 13:38:07 UTC (rev 5950) +++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/IPlainPropertyContainerMapper.cs 2011-06-18 15:57:58 UTC (rev 5951) @@ -28,11 +28,11 @@ { void Property<TProperty>(Expression<Func<TContainer, TProperty>> property); void Property<TProperty>(Expression<Func<TContainer, TProperty>> property, Action<IPropertyMapper> mapping); - void Property(string notVidiblePropertyOrFieldName, Action<IPropertyMapper> mapping); + void Property(string notVisiblePropertyOrFieldName, Action<IPropertyMapper> mapping); void ManyToOne<TProperty>(Expression<Func<TContainer, TProperty>> property, Action<IManyToOneMapper> mapping) where TProperty : class; void ManyToOne<TProperty>(Expression<Func<TContainer, TProperty>> property) where TProperty : class; - void ManyToOne<TProperty>(string notVidiblePropertyOrFieldName, Action<IManyToOneMapper> mapping) where TProperty : class; + void ManyToOne<TProperty>(string notVisiblePropertyOrFieldName, Action<IManyToOneMapper> mapping) where TProperty : class; } public interface IBasePlainPropertyContainerMapper<TContainer> : IMinimalPlainPropertyContainerMapper<TContainer> @@ -44,20 +44,20 @@ TComponent dynamicComponentTemplate, Action<IDynamicComponentMapper<TComponent>> mapping) where TComponent : class; - void Component<TComponent>(string notVidiblePropertyOrFieldName, + void Component<TComponent>(string notVisiblePropertyOrFieldName, Action<IComponentMapper<TComponent>> mapping) where TComponent : class; - void Component<TComponent>(string notVidiblePropertyOrFieldName) where TComponent : class; - void Component<TComponent>(string notVidiblePropertyOrFieldName, + void Component<TComponent>(string notVisiblePropertyOrFieldName) where TComponent : class; + void Component<TComponent>(string notVisiblePropertyOrFieldName, TComponent dynamicComponentTemplate, Action<IDynamicComponentMapper<TComponent>> mapping) where TComponent : class; void Any<TProperty>(Expression<Func<TContainer, TProperty>> property, System.Type idTypeOfMetaType, Action<IAnyMapper> mapping) where TProperty : class; - void Any<TProperty>(string notVidiblePropertyOrFieldName, System.Type idTypeOfMetaType, Action<IAnyMapper> mapping) where TProperty : class; + void Any<TProperty>(string notVisiblePropertyOrFieldName, System.Type idTypeOfMetaType, Action<IAnyMapper> mapping) where TProperty : class; } public interface IPlainPropertyContainerMapper<TContainer> : IBasePlainPropertyContainerMapper<TContainer> { void OneToOne<TProperty>(Expression<Func<TContainer, TProperty>> property, Action<IOneToOneMapper> mapping) where TProperty : class; - void OneToOne<TProperty>(string notVidiblePropertyOrFieldName, Action<IOneToOneMapper> mapping) where TProperty : class; + void OneToOne<TProperty>(string notVisiblePropertyOrFieldName, Action<IOneToOneMapper> mapping) where TProperty : class; } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Mapping/ByCode/IPropertyContainerMapper.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Mapping/ByCode/IPropertyContainerMapper.cs 2011-06-18 13:38:07 UTC (rev 5950) +++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/IPropertyContainerMapper.cs 2011-06-18 15:57:58 UTC (rev 5951) @@ -33,10 +33,10 @@ Action<ICollectionElementRelation<TElement>> mapping); void Set<TElement>(Expression<Func<TEntity, IEnumerable<TElement>>> property, Action<ISetPropertiesMapper<TEntity, TElement>> collectionMapping); - void Set<TElement>(string notVidiblePropertyOrFieldName, + void Set<TElement>(string notVisiblePropertyOrFieldName, Action<ISetPropertiesMapper<TEntity, TElement>> collectionMapping, Action<ICollectionElementRelation<TElement>> mapping); - void Set<TElement>(string notVidiblePropertyOrFieldName, + void Set<TElement>(string notVisiblePropertyOrFieldName, Action<ISetPropertiesMapper<TEntity, TElement>> collectionMapping); void Bag<TElement>(Expression<Func<TEntity, IEnumerable<TElement>>> property, @@ -44,10 +44,10 @@ Action<ICollectionElementRelation<TElement>> mapping); void Bag<TElement>(Expression<Func<TEntity, IEnumerable<TElement>>> property, Action<IBagPropertiesMapper<TEntity, TElement>> collectionMapping); - void Bag<TElement>(string notVidiblePropertyOrFieldName, + void Bag<TElement>(string notVisiblePropertyOrFieldName, Action<IBagPropertiesMapper<TEntity, TElement>> collectionMapping, Action<ICollectionElementRelation<TElement>> mapping); - void Bag<TElement>(string notVidiblePropertyOrFieldName, + void Bag<TElement>(string notVisiblePropertyOrFieldName, Action<IBagPropertiesMapper<TEntity, TElement>> collectionMapping); void List<TElement>(Expression<Func<TEntity, IEnumerable<TElement>>> property, @@ -55,10 +55,10 @@ Action<ICollectionElementRelation<TElement>> mapping); void List<TElement>(Expression<Func<TEntity, IEnumerable<TElement>>> property, Action<IListPropertiesMapper<TEntity, TElement>> collectionMapping); - void List<TElement>(string notVidiblePropertyOrFieldName, + void List<TElement>(string notVisiblePropertyOrFieldName, Action<IListPropertiesMapper<TEntity, TElement>> collectionMapping, Action<ICollectionElementRelation<TElement>> mapping); - void List<TElement>(string notVidiblePropertyOrFieldName, + void List<TElement>(string notVisiblePropertyOrFieldName, Action<IListPropertiesMapper<TEntity, TElement>> collectionMapping); void Map<TKey, TElement>(Expression<Func<TEntity, IDictionary<TKey, TElement>>> property, @@ -70,14 +70,14 @@ Action<ICollectionElementRelation<TElement>> mapping); void Map<TKey, TElement>(Expression<Func<TEntity, IDictionary<TKey, TElement>>> property, Action<IMapPropertiesMapper<TEntity, TKey, TElement>> collectionMapping); - void Map<TKey, TElement>(string notVidiblePropertyOrFieldName, + void Map<TKey, TElement>(string notVisiblePropertyOrFieldName, Action<IMapPropertiesMapper<TEntity, TKey, TElement>> collectionMapping, Action<IMapKeyRelation<TKey>> keyMapping, Action<ICollectionElementRelation<TElement>> mapping); - void Map<TKey, TElement>(string notVidiblePropertyOrFieldName, + void Map<TKey, TElement>(string notVisiblePropertyOrFieldName, Action<IMapPropertiesMapper<TEntity, TKey, TElement>> collectionMapping, Action<ICollectionElementRelation<TElement>> mapping); - void Map<TKey, TElement>(string notVidiblePropertyOrFieldName, + void Map<TKey, TElement>(string notVisiblePropertyOrFieldName, Action<IMapPropertiesMapper<TEntity, TKey, TElement>> collectionMapping); void IdBag<TElement>(Expression<Func<TEntity, IEnumerable<TElement>>> property, @@ -85,10 +85,10 @@ Action<ICollectionElementRelation<TElement>> mapping); void IdBag<TElement>(Expression<Func<TEntity, IEnumerable<TElement>>> property, Action<IIdBagPropertiesMapper<TEntity, TElement>> collectionMapping); - void IdBag<TElement>(string notVidiblePropertyOrFieldName, + void IdBag<TElement>(string notVisiblePropertyOrFieldName, Action<IIdBagPropertiesMapper<TEntity, TElement>> collectionMapping, Action<ICollectionElementRelation<TElement>> mapping); - void IdBag<TElement>(string notVidiblePropertyOrFieldName, + void IdBag<TElement>(string notVisiblePropertyOrFieldName, Action<IIdBagPropertiesMapper<TEntity, TElement>> collectionMapping); } Modified: trunk/nhibernate/src/NHibernate/Mapping/ByCode/ISubclassMapper.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Mapping/ByCode/ISubclassMapper.cs 2011-06-18 13:38:07 UTC (rev 5950) +++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/ISubclassMapper.cs 2011-06-18 15:57:58 UTC (rev 5951) @@ -10,7 +10,7 @@ public interface ISubclassMapper : ISubclassAttributesMapper, IPropertyContainerMapper { - void Join(string splitGroupId, Action<IJoinMapper> splittedMapping); + void Join(string splitGroupId, Action<IJoinMapper> splitMapping); } public interface ISubclassAttributesMapper<TEntity> : IEntityAttributesMapper, IEntitySqlsMapper where TEntity : class @@ -20,6 +20,6 @@ public interface ISubclassMapper<TEntity> : ISubclassAttributesMapper<TEntity>, IPropertyContainerMapper<TEntity> where TEntity : class { - void Join(string splitGroupId, Action<IJoinMapper<TEntity>> splittedMapping); + void Join(string splitGroupId, Action<IJoinMapper<TEntity>> splitMapping); } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/ClassMapper.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/ClassMapper.cs 2011-06-18 13:38:07 UTC (rev 5950) +++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/ClassMapper.cs 2011-06-18 15:57:58 UTC (rev 5951) @@ -236,7 +236,7 @@ classMapping.schemaaction = action.ToSchemaActionString(); } - public void Join(string splitGroupId, Action<IJoinMapper> splittedMapping) + public void Join(string splitGroupId, Action<IJoinMapper> splitMapping) { IJoinMapper splitGroup; if(!JoinMappers.TryGetValue(splitGroupId, out splitGroup)) @@ -248,7 +248,7 @@ classMapping.Items1 = classMapping.Items1 == null ? toAdd : classMapping.Items1.Concat(toAdd).ToArray(); } - splittedMapping(splitGroup); + splitMapping(splitGroup); } #endregion Modified: trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/ClassCustomizer.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/ClassCustomizer.cs 2011-06-18 13:38:07 UTC (rev 5950) +++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/ClassCustomizer.cs 2011-06-18 15:57:58 UTC (rev 5951) @@ -46,12 +46,12 @@ CustomizersHolder.AddCustomizer(typeof (TEntity), m => m.Id(member, idMapper)); } - public void Id(string notVidiblePropertyOrFieldName, Action<IIdMapper> idMapper) + public void Id(string notVisiblePropertyOrFieldName, Action<IIdMapper> idMapper) { MemberInfo member = null; - if (notVidiblePropertyOrFieldName != null) + if (notVisiblePropertyOrFieldName != null) { - member = typeof(TEntity).GetPropertyOrFieldMatchingName(notVidiblePropertyOrFieldName); + member = typeof(TEntity).GetPropertyOrFieldMatchingName(notVisiblePropertyOrFieldName); ExplicitDeclarationsHolder.AddAsPoid(member); } CustomizersHolder.AddCustomizer(typeof(TEntity), m => m.Id(member, idMapper)); @@ -69,14 +69,14 @@ idMapper(new ComponentAsIdCustomizer<TComponent>(ExplicitDeclarationsHolder, CustomizersHolder, propertyPath)); } - public void ComponentAsId<TComponent>(string notVidiblePropertyOrFieldName) where TComponent : class + public void ComponentAsId<TComponent>(string notVisiblePropertyOrFieldName) where TComponent : class { - ComponentAsId<TComponent>(notVidiblePropertyOrFieldName, x => { }); + ComponentAsId<TComponent>(notVisiblePropertyOrFieldName, x => { }); } - public void ComponentAsId<TComponent>(string notVidiblePropertyOrFieldName, Action<IComponentAsIdMapper<TComponent>> idMapper) where TComponent : class + public void ComponentAsId<TComponent>(string notVisiblePropertyOrFieldName, Action<IComponentAsIdMapper<TComponent>> idMapper) where TComponent : class { - var member = typeof(TEntity).GetPropertyOrFieldMatchingName(notVidiblePropertyOrFieldName); + var member = typeof(TEntity).GetPropertyOrFieldMatchingName(notVisiblePropertyOrFieldName); var propertyPath = new PropertyPath(null, member); idMapper(new ComponentAsIdCustomizer<TComponent>(ExplicitDeclarationsHolder, CustomizersHolder, propertyPath)); } @@ -127,9 +127,9 @@ CustomizersHolder.AddCustomizer(typeof(TEntity), (IClassMapper m) => m.Version(member, versionMapping)); } - public void Version(string notVidiblePropertyOrFieldName, Action<IVersionMapper> versionMapping) + public void Version(string notVisiblePropertyOrFieldName, Action<IVersionMapper> versionMapping) { - var member = typeof(TEntity).GetPropertyOrFieldMatchingName(notVidiblePropertyOrFieldName); + var member = typeof(TEntity).GetPropertyOrFieldMatchingName(notVisiblePropertyOrFieldName); ExplicitDeclarationsHolder.AddAsVersionProperty(member); CustomizersHolder.AddCustomizer(typeof(TEntity), (IClassMapper m) => m.Version(member, versionMapping)); } @@ -165,7 +165,7 @@ CustomizersHolder.AddCustomizer(typeof(TEntity), (IClassMapper m) => m.SchemaAction(action)); } - public void Join(string splitGroupId, Action<IJoinMapper<TEntity>> splittedMapping) + public void Join(string splitGroupId, Action<IJoinMapper<TEntity>> splitMapping) { // add the customizer only to create the JoinMapper instance CustomizersHolder.AddCustomizer(typeof(TEntity), (IClassMapper m) => m.Join(splitGroupId, j => { })); @@ -176,7 +176,7 @@ joinCustomizer = new JoinCustomizer<TEntity>(splitGroupId, ExplicitDeclarationsHolder, CustomizersHolder); JoinCustomizers.Add(splitGroupId, joinCustomizer); } - splittedMapping(joinCustomizer); + splitMapping(joinCustomizer); } public void EntityName(string value) Modified: trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/CollectionKeyCustomizer.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/CollectionKeyCustomizer.cs 2011-06-18 13:38:07 UTC (rev 5950) +++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/CollectionKeyCustomizer.cs 2011-06-18 15:57:58 UTC (rev 5951) @@ -50,9 +50,9 @@ CustomizersHolder.AddCustomizer(propertyPath, (ICollectionPropertiesMapper m) => m.Key(x => x.Update(consideredInUpdateQuery))); } - public void ForeignKey(string foreingKeyName) + public void ForeignKey(string foreignKeyName) { - CustomizersHolder.AddCustomizer(propertyPath, (ICollectionPropertiesMapper m) => m.Key(x => x.ForeignKey(foreingKeyName))); + CustomizersHolder.AddCustomizer(propertyPath, (ICollectionPropertiesMapper m) => m.Key(x => x.ForeignKey(foreignKeyName))); } public void NotNullable(bool notnull) Modified: trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/JoinCustomizer.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/JoinCustomizer.cs 2011-06-18 13:38:07 UTC (rev 5950) +++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/JoinCustomizer.cs 2011-06-18 15:57:58 UTC (rev 5951) @@ -117,12 +117,12 @@ base.RegisterPropertyMapping(property, mapping); } - protected override void RegisterNoVisiblePropertyMapping(string notVidiblePropertyOrFieldName, System.Action<IPropertyMapper> mapping) + protected override void RegisterNoVisiblePropertyMapping(string notVisiblePropertyOrFieldName, System.Action<IPropertyMapper> mapping) { - MemberInfo member = typeof(TEntity).GetPropertyOrFieldMatchingName(notVidiblePropertyOrFieldName); + MemberInfo member = typeof(TEntity).GetPropertyOrFieldMatchingName(notVisiblePropertyOrFieldName); ExplicitDeclarationsHolder.AddAsPropertySplit(new SplitDefinition(typeof(TEntity), splitGroupId, member)); - base.RegisterNoVisiblePropertyMapping(notVidiblePropertyOrFieldName, mapping); + base.RegisterNoVisiblePropertyMapping(notVisiblePropertyOrFieldName, mapping); } protected override void RegisterComponentMapping<TComponent>(Expression<Func<TEntity, TComponent>> property, Action<IComponentMapper<TComponent>> mapping) Modified: trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/JoinKeyCustomizer.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/JoinKeyCustomizer.cs 2011-06-18 13:38:07 UTC (rev 5950) +++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/JoinKeyCustomizer.cs 2011-06-18 15:57:58 UTC (rev 5951) @@ -47,9 +47,9 @@ CustomizersHolder.AddCustomizer(typeof(TEntity), (IJoinAttributesMapper m) => m.Key(x => x.Update(consideredInUpdateQuery))); } - public void ForeignKey(string foreingKeyName) + public void ForeignKey(string foreignKeyName) { - CustomizersHolder.AddCustomizer(typeof(TEntity), (IJoinAttributesMapper m) => m.Key(x => x.ForeignKey(foreingKeyName))); + CustomizersHolder.AddCustomizer(typeof(TEntity), (IJoinAttributesMapper m) => m.Key(x => x.ForeignKey(foreignKeyName))); } public void NotNullable(bool notnull) Modified: trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/JoinedSubclassKeyCustomizer.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/JoinedSubclassKeyCustomizer.cs 2011-06-18 13:38:07 UTC (rev 5950) +++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/JoinedSubclassKeyCustomizer.cs 2011-06-18 15:57:58 UTC (rev 5951) @@ -47,9 +47,9 @@ CustomizersHolder.AddCustomizer(typeof (TEntity), (IJoinedSubclassAttributesMapper m) => m.Key(x => x.Update(consideredInUpdateQuery))); } - public void ForeignKey(string foreingKeyName) + public void ForeignKey(string foreignKeyName) { - CustomizersHolder.AddCustomizer(typeof (TEntity), (IJoinedSubclassAttributesMapper m) => m.Key(x => x.ForeignKey(foreingKeyName))); + CustomizersHolder.AddCustomizer(typeof (TEntity), (IJoinedSubclassAttributesMapper m) => m.Key(x => x.ForeignKey(foreignKeyName))); } public void NotNullable(bool notnull) Modified: trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/ManyToManyCustomizer.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/ManyToManyCustomizer.cs 2011-06-18 13:38:07 UTC (rev 5950) +++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/ManyToManyCustomizer.cs 2011-06-18 15:57:58 UTC (rev 5951) @@ -60,9 +60,9 @@ customizersHolder.AddCustomizer(propertyPath, (IManyToManyMapper x) => x.Lazy(lazyRelation)); } - public void ForeignKey(string foreingKeyName) + public void ForeignKey(string foreignKeyName) { - customizersHolder.AddCustomizer(propertyPath, (IManyToManyMapper x) => x.ForeignKey(foreingKeyName)); + customizersHolder.AddCustomizer(propertyPath, (IManyToManyMapper x) => x.ForeignKey(foreignKeyName)); } #endregion Modified: trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/NaturalIdCustomizer.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/NaturalIdCustomizer.cs 2011-06-18 13:38:07 UTC (rev 5950) +++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/NaturalIdCustomizer.cs 2011-06-18 15:57:58 UTC (rev 5951) @@ -16,14 +16,14 @@ base.RegisterPropertyMapping(property, mapping); } - protected override void RegisterNoVisiblePropertyMapping(string notVidiblePropertyOrFieldName, System.Action<IPropertyMapper> mapping) + protected override void RegisterNoVisiblePropertyMapping(string notVisiblePropertyOrFieldName, System.Action<IPropertyMapper> mapping) { - MemberInfo member = typeof(TEntity).GetPropertyOrFieldMatchingName(notVidiblePropertyOrFieldName); + MemberInfo member = typeof(TEntity).GetPropertyOrFieldMatchingName(notVisiblePropertyOrFieldName); MemberInfo memberOf = member.GetMemberFromReflectedType(typeof(TEntity)); ExplicitDeclarationsHolder.AddAsNaturalId(member); ExplicitDeclarationsHolder.AddAsNaturalId(memberOf); - base.RegisterNoVisiblePropertyMapping(notVidiblePropertyOrFieldName, mapping); + base.RegisterNoVisiblePropertyMapping(notVisiblePropertyOrFieldName, mapping); } protected override void RegisterComponentMapping<TComponent>(System.Linq.Expressions.Expression<System.Func<TEntity, TComponent>> property, System.Action<IComponentMapper<TComponent>> mapping) Modified: trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/PropertyContainerCustomizer.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/PropertyContainerCustomizer.cs 2011-06-18 13:38:07 UTC (rev 5950) +++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/PropertyContainerCustomizer.cs 2011-06-18 15:57:58 UTC (rev 5951) @@ -46,16 +46,16 @@ RegistePropertyMapping(mapping, member, memberOf); } - public void Property(string notVidiblePropertyOrFieldName, Action<IPropertyMapper> mapping) + public void Property(string notVisiblePropertyOrFieldName, Action<IPropertyMapper> mapping) { - RegisterNoVisiblePropertyMapping(notVidiblePropertyOrFieldName, mapping); + RegisterNoVisiblePropertyMapping(notVisiblePropertyOrFieldName, mapping); } - protected virtual void RegisterNoVisiblePropertyMapping(string notVidiblePropertyOrFieldName, Action<IPropertyMapper> mapping) + protected virtual void RegisterNoVisiblePropertyMapping(string notVisiblePropertyOrFieldName, Action<IPropertyMapper> mapping) { // even seems repetitive, before unify this registration with the registration using Expression take in account that reflection operations // done unsing expressions are faster than those done with pure reflection. - MemberInfo member = GetPropertyOrFieldMatchingNameOrThrow(notVidiblePropertyOrFieldName); + MemberInfo member = GetPropertyOrFieldMatchingNameOrThrow(notVisiblePropertyOrFieldName); MemberInfo memberOf = member.GetMemberFromReflectedType(typeof(TEntity)); RegistePropertyMapping(mapping, member, memberOf); } @@ -344,162 +344,162 @@ } } - public void Set<TElement>(string notVidiblePropertyOrFieldName, Action<ISetPropertiesMapper<TEntity, TElement>> collectionMapping, Action<ICollectionElementRelation<TElement>> mapping) + public void Set<TElement>(string notVisiblePropertyOrFieldName, Action<ISetPropertiesMapper<TEntity, TElement>> collectionMapping, Action<ICollectionElementRelation<TElement>> mapping) { - MemberInfo member = GetPropertyOrFieldMatchingNameOrThrow(notVidiblePropertyOrFieldName); + MemberInfo member = GetPropertyOrFieldMatchingNameOrThrow(notVisiblePropertyOrFieldName); var collectionElementType = member.GetPropertyOrFieldType().DetermineCollectionElementType(); if(!typeof(TElement).Equals(collectionElementType)) { throw new MappingException(string.Format("Wrong collection element type. For the property/field '{0}' of {1} was expected a collection of {2} but was {3}", - notVidiblePropertyOrFieldName, typeof (TEntity).FullName, typeof (TElement).Name, collectionElementType.Name)); + notVisiblePropertyOrFieldName, typeof (TEntity).FullName, typeof (TElement).Name, collectionElementType.Name)); } MemberInfo memberOf = member.GetMemberFromReflectedType(typeof(TEntity)); RegisterSetMapping<TElement>(collectionMapping, mapping, member, memberOf); } - public void Set<TElement>(string notVidiblePropertyOrFieldName, Action<ISetPropertiesMapper<TEntity, TElement>> collectionMapping) + public void Set<TElement>(string notVisiblePropertyOrFieldName, Action<ISetPropertiesMapper<TEntity, TElement>> collectionMapping) { - Set(notVidiblePropertyOrFieldName, collectionMapping, x => { }); + Set(notVisiblePropertyOrFieldName, collectionMapping, x => { }); } - public void Bag<TElement>(string notVidiblePropertyOrFieldName, Action<IBagPropertiesMapper<TEntity, TElement>> collectionMapping, Action<ICollectionElementRelation<TElement>> mapping) + public void Bag<TElement>(string notVisiblePropertyOrFieldName, Action<IBagPropertiesMapper<TEntity, TElement>> collectionMapping, Action<ICollectionElementRelation<TElement>> mapping) { - MemberInfo member = GetPropertyOrFieldMatchingNameOrThrow(notVidiblePropertyOrFieldName); + MemberInfo member = GetPropertyOrFieldMatchingNameOrThrow(notVisiblePropertyOrFieldName); var collectionElementType = member.GetPropertyOrFieldType().DetermineCollectionElementType(); if (!typeof(TElement).Equals(collectionElementType)) { throw new MappingException(string.Format("Wrong collection element type. For the property/field '{0}' of {1} was expected a collection of {2} but was {3}", - notVidiblePropertyOrFieldName, typeof(TEntity).FullName, typeof(TElement).Name, collectionElementType.Name)); + notVisiblePropertyOrFieldName, typeof(TEntity).FullName, typeof(TElement).Name, collectionElementType.Name)); } MemberInfo memberOf = member.GetMemberFromReflectedType(typeof(TEntity)); RegisterBagMapping<TElement>(collectionMapping, mapping, member, memberOf); } - public void Bag<TElement>(string notVidiblePropertyOrFieldName, Action<IBagPropertiesMapper<TEntity, TElement>> collectionMapping) + public void Bag<TElement>(string notVisiblePropertyOrFieldName, Action<IBagPropertiesMapper<TEntity, TElement>> collectionMapping) { - Bag(notVidiblePropertyOrFieldName, collectionMapping, x => { }); + Bag(notVisiblePropertyOrFieldName, collectionMapping, x => { }); } - public void List<TElement>(string notVidiblePropertyOrFieldName, Action<IListPropertiesMapper<TEntity, TElement>> collectionMapping, Action<ICollectionElementRelation<TElement>> mapping) + public void List<TElement>(string notVisiblePropertyOrFieldName, Action<IListPropertiesMapper<TEntity, TElement>> collectionMapping, Action<ICollectionElementRelation<TElement>> mapping) { - MemberInfo member = GetPropertyOrFieldMatchingNameOrThrow(notVidiblePropertyOrFieldName); + MemberInfo member = GetPropertyOrFieldMatchingNameOrThrow(notVisiblePropertyOrFieldName); var collectionElementType = member.GetPropertyOrFieldType().DetermineCollectionElementType(); if (!typeof(TElement).Equals(collectionElementType)) { throw new MappingException(string.Format("Wrong collection element type. For the property/field '{0}' of {1} was expected a collection of {2} but was {3}", - notVidiblePropertyOrFieldName, typeof(TEntity).FullName, typeof(TElement).Name, collectionElementType.Name)); + notVisiblePropertyOrFieldName, typeof(TEntity).FullName, typeof(TElement).Name, collectionElementType.Name)); } MemberInfo memberOf = member.GetMemberFromReflectedType(typeof(TEntity)); RegisterListMapping<TElement>(collectionMapping, mapping, member, memberOf); } - public void List<TElement>(string notVidiblePropertyOrFieldName, Action<IListPropertiesMapper<TEntity, TElement>> collectionMapping) + public void List<TElement>(string notVisiblePropertyOrFieldName, Action<IListPropertiesMapper<TEntity, TElement>> collectionMapping) { - List(notVidiblePropertyOrFieldName, collectionMapping, x => { }); + List(notVisiblePropertyOrFieldName, collectionMapping, x => { }); } - public void Map<TKey, TElement>(string notVidiblePropertyOrFieldName, Action<IMapPropertiesMapper<TEntity, TKey, TElement>> collectionMapping, Action<IMapKeyRelation<TKey>> keyMapping, Action<ICollectionElementRelation<TElement>> mapping) + public void Map<TKey, TElement>(string notVisiblePropertyOrFieldName, Action<IMapPropertiesMapper<TEntity, TKey, TElement>> collectionMapping, Action<IMapKeyRelation<TKey>> keyMapping, Action<ICollectionElementRelation<TElement>> mapping) { - MemberInfo member = GetPropertyOrFieldMatchingNameOrThrow(notVidiblePropertyOrFieldName); + MemberInfo member = GetPropertyOrFieldMatchingNameOrThrow(notVisiblePropertyOrFieldName); var propertyOrFieldType = member.GetPropertyOrFieldType(); var keyType = propertyOrFieldType.DetermineDictionaryKeyType(); var collectionElementType = propertyOrFieldType.DetermineDictionaryValueType(); if (!typeof(TElement).Equals(collectionElementType) || !typeof(TKey).Equals(keyType)) { throw new MappingException(string.Format("Wrong collection element type. For the property/field '{0}' of {1} was expected a dictionary of {2}/{3} but was {4}/{5}", - notVidiblePropertyOrFieldName, typeof(TEntity).FullName, typeof(TKey).Name, keyType.Name ,typeof(TElement).Name, collectionElementType.Name)); + notVisiblePropertyOrFieldName, typeof(TEntity).FullName, typeof(TKey).Name, keyType.Name ,typeof(TElement).Name, collectionElementType.Name)); } MemberInfo memberOf = member.GetMemberFromReflectedType(typeof(TEntity)); RegisterMapMapping<TKey, TElement>(collectionMapping, keyMapping, mapping, member, memberOf); } - public void Map<TKey, TElement>(string notVidiblePropertyOrFieldName, Action<IMapPropertiesMapper<TEntity, TKey, TElement>> collectionMapping, Action<ICollectionElementRelation<TElement>> mapping) + public void Map<TKey, TElement>(string notVisiblePropertyOrFieldName, Action<IMapPropertiesMapper<TEntity, TKey, TElement>> collectionMapping, Action<ICollectionElementRelation<TElement>> mapping) { - Map(notVidiblePropertyOrFieldName, collectionMapping, x => { }, mapping); + Map(notVisiblePropertyOrFieldName, collectionMapping, x => { }, mapping); } - public void Map<TKey, TElement>(string notVidiblePropertyOrFieldName, Action<IMapPropertiesMapper<TEntity, TKey, TElement>> collectionMapping) + public void Map<TKey, TElement>(string notVisiblePropertyOrFieldName, Action<IMapPropertiesMapper<TEntity, TKey, TElement>> collectionMapping) { - Map(notVidiblePropertyOrFieldName, collectionMapping, x => { }, y => { }); + Map(notVisiblePropertyOrFieldName, collectionMapping, x => { }, y => { }); } - public void IdBag<TElement>(string notVidiblePropertyOrFieldName, Action<IIdBagPropertiesMapper<TEntity, TElement>> collectionMapping, Action<ICollectionElementRelation<TElement>> mapping) + public void IdBag<TElement>(string notVisiblePropertyOrFieldName, Action<IIdBagPropertiesMapper<TEntity, TElement>> collectionMapping, Action<ICollectionElementRelation<TElement>> mapping) { - MemberInfo member = GetPropertyOrFieldMatchingNameOrThrow(notVidiblePropertyOrFieldName); + MemberInfo member = GetPropertyOrFieldMatchingNameOrThrow(notVisiblePropertyOrFieldName); var collectionElementType = member.GetPropertyOrFieldType().DetermineCollectionElementType(); if (!typeof(TElement).Equals(collectionElementType)) { throw new MappingException(string.Format("Wrong collection element type. For the property/field '{0}' of {1} was expected a collection of {2} but was {3}", - notVidiblePropertyOrFieldName, typeof(TEntity).FullName, typeof(TElement).Name, collectionElementType.Name)); + notVisiblePropertyOrFieldName, typeof(TEntity).FullName, typeof(TElement).Name, collectionElementType.Name)); } MemberInfo memberOf = member.GetMemberFromReflectedType(typeof(TEntity)); RegisterIdBagMapping<TElement>(collectionMapping, mapping, member, memberOf); } - public void IdBag<TElement>(string notVidiblePropertyOrFieldName, Action<IIdBagPropertiesMapper<TEntity, TElement>> collectionMapping) + public void IdBag<TElement>(string notVisiblePropertyOrFieldName, Action<IIdBagPropertiesMapper<TEntity, TElement>> collectionMapping) { - IdBag(notVidiblePropertyOrFieldName, collectionMapping, x => { }); + IdBag(notVisiblePropertyOrFieldName, collectionMapping, x => { }); } - public void ManyToOne<TProperty>(string notVidiblePropertyOrFieldName, Action<IManyToOneMapper> mapping) where TProperty : class + public void ManyToOne<TProperty>(string notVisiblePropertyOrFieldName, Action<IManyToOneMapper> mapping) where TProperty : class { - MemberInfo member = GetPropertyOrFieldMatchingNameOrThrow(notVidiblePropertyOrFieldName); + MemberInfo member = GetPropertyOrFieldMatchingNameOrThrow(notVisiblePropertyOrFieldName); var propertyOrFieldType = member.GetPropertyOrFieldType(); if (!typeof(TProperty).Equals(propertyOrFieldType)) { throw new MappingException(string.Format("Wrong relation type. For the property/field '{0}' of {1} was expected a many-to-one with {2} but was {3}", - notVidiblePropertyOrFieldName, typeof(TEntity).FullName, typeof(TProperty).Name, propertyOrFieldType.Name)); + notVisiblePropertyOrFieldName, typeof(TEntity).FullName, typeof(TProperty).Name, propertyOrFieldType.Name)); } MemberInfo memberOf = member.GetMemberFromReflectedType(typeof(TEntity)); RegisterManyToOneMapping<TProperty>(mapping, member, memberOf); } - public void Component<TComponent>(string notVidiblePropertyOrFieldName, Action<IComponentMapper<TComponent>> mapping) where TComponent : class + public void Component<TComponent>(string notVisiblePropertyOrFieldName, Action<IComponentMapper<TComponent>> mapping) where TComponent : class { - MemberInfo member = GetPropertyOrFieldMatchingNameOrThrow(notVidiblePropertyOrFieldName); + MemberInfo member = GetPropertyOrFieldMatchingNameOrThrow(notVisiblePropertyOrFieldName); var propertyOrFieldType = member.GetPropertyOrFieldType(); if (!typeof(TComponent).Equals(propertyOrFieldType)) { throw new MappingException(string.Format("Wrong relation type. For the property/field '{0}' of {1} was expected a component of {2} but was {3}", - notVidiblePropertyOrFieldName, typeof(TEntity).FullName, typeof(TComponent).Name, propertyOrFieldType.Name)); + notVisiblePropertyOrFieldName, typeof(TEntity).FullName, typeof(TComponent).Name, propertyOrFieldType.Name)); } MemberInfo memberOf = member.GetMemberFromReflectedType(typeof(TEntity)); RegisterComponentMapping<TComponent>(mapping, member, memberOf); } - public void Component<TComponent>(string notVidiblePropertyOrFieldName) where TComponent : class + public void Component<TComponent>(string notVisiblePropertyOrFieldName) where TComponent : class { - Component<TComponent>(notVidiblePropertyOrFieldName, x => { }); + Component<TComponent>(notVisiblePropertyOrFieldName, x => { }); } - public void Component<TComponent>(string notVidiblePropertyOrFieldName, TComponent dynamicComponentTemplate, Action<IDynamicComponentMapper<TComponent>> mapping) where TComponent : class + public void Component<TComponent>(string notVisiblePropertyOrFieldName, TComponent dynamicComponentTemplate, Action<IDynamicComponentMapper<TComponent>> mapping) where TComponent : class { - MemberInfo member = GetPropertyOrFieldMatchingNameOrThrow(notVidiblePropertyOrFieldName); + MemberInfo member = GetPropertyOrFieldMatchingNameOrThrow(notVisiblePropertyOrFieldName); MemberInfo memberOf = member.GetMemberFromReflectedType(typeof(TEntity)); RegisterDynamicComponentMapping<TComponent>(mapping, member, memberOf); } - public void Any<TProperty>(string notVidiblePropertyOrFieldName, System.Type idTypeOfMetaType, Action<IAnyMapper> mapping) where TProperty : class + public void Any<TProperty>(string notVisiblePropertyOrFieldName, System.Type idTypeOfMetaType, Action<IAnyMapper> mapping) where TProperty : class { - MemberInfo member = GetPropertyOrFieldMatchingNameOrThrow(notVidiblePropertyOrFieldName); + MemberInfo member = GetPropertyOrFieldMatchingNameOrThrow(notVisiblePropertyOrFieldName); var propertyOrFieldType = member.GetPropertyOrFieldType(); if (!typeof(TProperty).Equals(propertyOrFieldType)) { throw new MappingException(string.Format("Wrong relation type. For the property/field '{0}' of {1} was expected a heterogeneous (any) of type {2} but was {3}", - notVidiblePropertyOrFieldName, typeof(TEntity).FullName, typeof(TProperty).Name, propertyOrFieldType.Name)); + notVisiblePropertyOrFieldName, typeof(TEntity).FullName, typeof(TProperty).Name, propertyOrFieldType.Name)); } MemberInfo memberOf = member.GetMemberFromReflectedType(typeof(TEntity)); RegisterAnyMapping<TProperty>(mapping, idTypeOfMetaType, member, memberOf); } - public void OneToOne<TProperty>(string notVidiblePropertyOrFieldName, Action<IOneToOneMapper> mapping) where TProperty : class + public void OneToOne<TProperty>(string notVisiblePropertyOrFieldName, Action<IOneToOneMapper> mapping) where TProperty : class { - MemberInfo member = GetPropertyOrFieldMatchingNameOrThrow(notVidiblePropertyOrFieldName); + MemberInfo member = GetPropertyOrFieldMatchingNameOrThrow(notVisiblePropertyOrFieldName); var propertyOrFieldType = member.GetPropertyOrFieldType(); if (!typeof(TProperty).Equals(propertyOrFieldType)) { throw new MappingException(string.Format("Wrong relation type. For the property/field '{0}' of {1} was expected a one-to-one with {2} but was {3}", - notVidiblePropertyOrFieldName, typeof(TEntity).FullName, typeof(TProperty).Name, propertyOrFieldType.Name)); + notVisiblePropertyOrFieldName, typeof(TEntity).FullName, typeof(TProperty).Name, propertyOrFieldType.Name)); } MemberInfo memberOf = member.GetMemberFromReflectedType(typeof(TEntity)); RegisterOneToOneMapping<TProperty>(mapping, member, memberOf); Modified: trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/SubclassCustomizer.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/SubclassCustomizer.cs 2011-06-18 13:38:07 UTC (rev 5950) +++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/SubclassCustomizer.cs 2011-06-18 15:57:58 UTC (rev 5951) @@ -35,7 +35,7 @@ get { return joinCustomizers ?? (joinCustomizers = new Dictionary<string, IJoinMapper<TEntity>>()); } } - public void Join(string splitGroupId, Action<IJoinMapper<TEntity>> splittedMapping) + public void Join(string splitGroupId, Action<IJoinMapper<TEntity>> splitMapping) { // add the customizer only to ensure the creation of the JoinMapper instance for the group CustomizersHolder.AddCustomizer(typeof(TEntity), (ISubclassMapper m) => m.Join(splitGroupId, j => { })); @@ -46,7 +46,7 @@ joinCustomizer = new JoinCustomizer<TEntity>(splitGroupId, ExplicitDeclarationsHolder, CustomizersHolder); JoinCustomizers.Add(splitGroupId, joinCustomizer); } - splittedMapping(joinCustomizer); + splitMapping(joinCustomizer); } #region Implementation of IEntityAttributesMapper Modified: trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/KeyMapper.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/KeyMapper.cs 2011-06-18 13:38:07 UTC (rev 5950) +++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/KeyMapper.cs 2011-06-18 15:57:58 UTC (rev 5951) @@ -119,14 +119,14 @@ mapping.unique = mapping.uniqueSpecified = unique; } - public void ForeignKey(string foreingKeyName) + public void ForeignKey(string foreignKeyName) { - if (foreingKeyName == null) + if (foreignKeyName == null) { mapping.foreignkey = null; return; } - string nameToAssign = foreingKeyName.Trim(); + string nameToAssign = foreignKeyName.Trim(); if (string.Empty.Equals(nameToAssign)) { mapping.foreignkey = "none"; Modified: trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/ManyToManyMapper.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/ManyToManyMapper.cs 2011-06-18 13:38:07 UTC (rev 5950) +++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/ManyToManyMapper.cs 2011-06-18 15:57:58 UTC (rev 5951) @@ -161,9 +161,9 @@ } } - public void ForeignKey(string foreingKeyName) + public void ForeignKey(string foreignKeyName) { - manyToMany.foreignkey = foreingKeyName; + manyToMany.foreignkey = foreignKeyName; } #endregion Modified: trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/SubclassMapper.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/SubclassMapper.cs 2011-06-18 13:38:07 UTC (rev 5950) +++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/SubclassMapper.cs 2011-06-18 15:57:58 UTC (rev 5951) @@ -59,7 +59,7 @@ classMapping.extends = baseType.GetShortClassName(MapDoc); } - public void Join(string splitGroupId, Action<IJoinMapper> splittedMapping) + public void Join(string splitGroupId, Action<IJoinMapper> splitMapping) { IJoinMapper splitGroup; if (!JoinMappers.TryGetValue(splitGroupId, out splitGroup)) @@ -71,7 +71,7 @@ classMapping.join = classMapping.join == null ? toAdd : classMapping.join.Concat(toAdd).ToArray(); } - splittedMapping(splitGroup); + splitMapping(splitGroup); } #endregion Modified: trunk/nhibernate/src/NHibernate/Mapping/ByCode/ModelMapper.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Mapping/ByCode/ModelMapper.cs 2011-06-18 13:38:07 UTC (rev 5950) +++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/ModelMapper.cs 2011-06-18 15:57:58 UTC (rev 5951) @@ -667,7 +667,7 @@ IJoinMapper joinMapper; if (propertiesOfTheGroup.Count > 0 && classMapper.JoinMappers.TryGetValue(groupId, out joinMapper)) { - MapSplittedProperties(type, propertiesOfTheGroup, joinMapper); + MapSplitProperties(type, propertiesOfTheGroup, joinMapper); propertiesInSplits.UnionWith(propertiesOfTheGroup); } } @@ -704,13 +704,13 @@ private System.Type GetEntityBaseType(System.Type type) { - System.Type analizingType = type; - while (analizingType != null && analizingType != typeof (object)) + System.Type analyzingType = type; + while (analyzingType != null && analyzingType != typeof (object)) { - analizingType = analizingType.BaseType; - if (modelInspector.IsEntity(analizingType)) + analyzingType = analyzingType.BaseType; + if (modelInspector.IsEntity(analyzingType)) { - return analizingType; + return analyzingType; } } return type.GetInterfaces().FirstOrDefault(i => modelInspector.IsEntity(i)); @@ -787,7 +787,7 @@ IJoinMapper joinMapper; if (propertiesOfTheGroup.Count > 0 && classMapper.JoinMappers.TryGetValue(groupId, out joinMapper)) { - MapSplittedProperties(type, propertiesOfTheGroup, joinMapper); + MapSplitProperties(type, propertiesOfTheGroup, joinMapper); propertiesInSplits.UnionWith(propertiesOfTheGroup); } } @@ -796,7 +796,7 @@ InvokeAfterMapClass(type, classMapper); } - private void MapSplittedProperties(System.Type propertiesContainerType, IEnumerable<MemberInfo> propertiesToMap, IJoinMapper propertiesContainer) + private void MapSplitProperties(System.Type propertiesContainerType, IEnumerable<MemberInfo> propertiesToMap, IJoinMapper propertiesContainer) { foreach (var property in propertiesToMap) { Modified: trunk/nhibernate/src/NHibernate/Mapping/ByCode/PropertyToField.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Mapping/ByCode/PropertyToField.cs 2011-06-18 13:38:07 UTC (rev 5950) +++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/PropertyToField.cs 2011-06-18 15:57:58 UTC (rev 5951) @@ -7,7 +7,7 @@ { public class PropertyToField { - private static readonly Dictionary<string, IFieldNamingStrategy> FieldNamningStrategies = new Dictionary<string, IFieldNamingStrategy> + private static readonly Dictionary<string, IFieldNamingStrategy> FieldNamingStrategies = new Dictionary<string, IFieldNamingStrategy> { {"camelcase", new CamelCaseStrategy()}, {"camelcase-underscore", new CamelCaseUnderscoreStrategy()}, @@ -27,14 +27,14 @@ get { // please leave it as no read-only; the user may need to add his strategies or remove existing if he no want his people use it. - return FieldNamningStrategies; + return FieldNamingStrategies; } } public static FieldInfo GetBackFieldInfo(PropertyInfo subject) { const BindingFlags defaultBinding = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly; - return (from s in FieldNamningStrategies.Values + return (from s in FieldNamingStrategies.Values let field = subject.DeclaringType.GetField(s.GetFieldName(subject.Name), defaultBinding) where field != null select field).FirstOrDefault(); Modified: trunk/nhibernate/src/NHibernate/Mapping/ByCode/SimpleModelInspector.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Mapping/ByCode/SimpleModelInspector.cs 2011-06-18 13:38:07 UTC (rev 5950) +++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/SimpleModelInspector.cs 2011-06-18 15:57:58 UTC (rev 5951) @@ -259,7 +259,7 @@ } if (memberType.IsGenericType) { - return memberType.GetGenericIntercafesTypeDefinitions().Contains(typeof(IDictionary<,>)); + return memberType.GetGenericInterfaceTypeDefinitions().Contains(typeof(IDictionary<,>)); } return false; } @@ -300,7 +300,7 @@ } if (memberType.IsGenericType) { - return memberType.GetGenericIntercafesTypeDefinitions().Contains(typeof(Iesi.Collections.Generic.ISet<>)); + return memberType.GetGenericInterfaceTypeDefinitions().Contains(typeof(Iesi.Collections.Generic.ISet<>)); } return false; } Modified: trunk/nhibernate/src/NHibernate/Mapping/ByCode/TypeExtensions.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Mapping/ByCode/TypeExtensions.cs 2011-06-18 13:38:07 UTC (rev 5950) +++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/TypeExtensions.cs 2011-06-18 15:57:58 UTC (rev 5951) @@ -30,11 +30,11 @@ public static IEnumerable<System.Type> GetHierarchyFromBase(this System.Type type) { var typeHierarchy = new List<System.Type>(); - System.Type analizingType = type; - while (analizingType != null && analizingType != typeof (object)) + System.Type analyzingType = type; + while (analyzingType != null && analyzingType != typeof (object)) { - typeHierarchy.Add(analizingType); - analizingType = analizingType.BaseType; + typeHierarchy.Add(analyzingType); + analyzingType = analyzingTy... [truncated message content] |
From: <fab...@us...> - 2011-06-18 13:38:13
|
Revision: 5950 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5950&view=rev Author: fabiomaulo Date: 2011-06-18 13:38:07 +0000 (Sat, 18 Jun 2011) Log Message: ----------- Removed no more needed code Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Hql/Classic/QueryTranslator.cs trunk/nhibernate/src/NHibernate/Hql/IParameterTranslations.cs trunk/nhibernate/src/NHibernate/Param/ParameterTranslationsImpl.cs Modified: trunk/nhibernate/src/NHibernate/Hql/Classic/QueryTranslator.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Classic/QueryTranslator.cs 2011-06-18 13:30:39 UTC (rev 5949) +++ trunk/nhibernate/src/NHibernate/Hql/Classic/QueryTranslator.cs 2011-06-18 13:38:07 UTC (rev 5950) @@ -1819,11 +1819,6 @@ return queryTraslator.namedParameters.Keys; } - public int[] GetNamedParameterSqlLocations(string name) - { - return new int[0]; - } - public IType GetNamedParameterExpectedType(string name) { return null; Modified: trunk/nhibernate/src/NHibernate/Hql/IParameterTranslations.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/IParameterTranslations.cs 2011-06-18 13:30:39 UTC (rev 5949) +++ trunk/nhibernate/src/NHibernate/Hql/IParameterTranslations.cs 2011-06-18 13:38:07 UTC (rev 5950) @@ -15,8 +15,6 @@ IEnumerable<string> GetNamedParameterNames(); - int[] GetNamedParameterSqlLocations(string name); - IType GetNamedParameterExpectedType(string name); } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Param/ParameterTranslationsImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Param/ParameterTranslationsImpl.cs 2011-06-18 13:30:39 UTC (rev 5949) +++ trunk/nhibernate/src/NHibernate/Param/ParameterTranslationsImpl.cs 2011-06-18 13:38:07 UTC (rev 5950) @@ -82,11 +82,6 @@ return _namedParameters.Keys; } - public int[] GetNamedParameterSqlLocations(string name) - { - return GetNamedParameterInfo(name).SqlLocations; - } - public IType GetNamedParameterExpectedType(string name) { return GetNamedParameterInfo(name).ExpectedType; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2011-06-18 13:30:45
|
Revision: 5949 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5949&view=rev Author: fabiomaulo Date: 2011-06-18 13:30:39 +0000 (Sat, 18 Jun 2011) Log Message: ----------- Removed no more needed code Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Engine/Query/NamedParameterDescriptor.cs trunk/nhibernate/src/NHibernate/Engine/Query/ParameterMetadata.cs trunk/nhibernate/src/NHibernate/Engine/Query/QueryPlanCache.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Loader/QueryLoader.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QueryTranslatorImpl.cs trunk/nhibernate/src/NHibernate/Hql/Classic/QueryTranslator.cs trunk/nhibernate/src/NHibernate/Linq/Visitors/HqlGeneratorExpressionTreeVisitor.cs trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/ProcessSkip.cs trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/ProcessTake.cs trunk/nhibernate/src/NHibernate/Loader/Collection/SubselectCollectionLoader.cs trunk/nhibernate/src/NHibernate/Loader/Collection/SubselectOneToManyLoader.cs trunk/nhibernate/src/NHibernate/Loader/Criteria/CriteriaLoader.cs trunk/nhibernate/src/NHibernate/Loader/Custom/CustomLoader.cs trunk/nhibernate/src/NHibernate/Loader/Loader.cs Modified: trunk/nhibernate/src/NHibernate/Engine/Query/NamedParameterDescriptor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Engine/Query/NamedParameterDescriptor.cs 2011-06-18 13:14:46 UTC (rev 5948) +++ trunk/nhibernate/src/NHibernate/Engine/Query/NamedParameterDescriptor.cs 2011-06-18 13:30:39 UTC (rev 5949) @@ -9,14 +9,12 @@ { private readonly string name; private readonly IType expectedType; - private readonly int[] sourceLocations; private readonly bool jpaStyle; - public NamedParameterDescriptor(string name, IType expectedType, int[] sourceLocations, bool jpaStyle) + public NamedParameterDescriptor(string name, IType expectedType, bool jpaStyle) { this.name = name; this.expectedType = expectedType; - this.sourceLocations = sourceLocations; this.jpaStyle = jpaStyle; } @@ -30,11 +28,6 @@ get { return expectedType; } } - public int[] SourceLocations - { - get { return sourceLocations; } - } - /// <summary> /// Not supported yet (AST parse needed) /// </summary> Modified: trunk/nhibernate/src/NHibernate/Engine/Query/ParameterMetadata.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Engine/Query/ParameterMetadata.cs 2011-06-18 13:14:46 UTC (rev 5948) +++ trunk/nhibernate/src/NHibernate/Engine/Query/ParameterMetadata.cs 2011-06-18 13:30:39 UTC (rev 5949) @@ -76,11 +76,5 @@ { return GetNamedParameterDescriptor(name).ExpectedType; } - - public int[] GetNamedParameterSourceLocations(string name) - { - return GetNamedParameterDescriptor(name).SourceLocations; - } - } } Modified: trunk/nhibernate/src/NHibernate/Engine/Query/QueryPlanCache.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Engine/Query/QueryPlanCache.cs 2011-06-18 13:14:46 UTC (rev 5948) +++ trunk/nhibernate/src/NHibernate/Engine/Query/QueryPlanCache.cs 2011-06-18 13:30:39 UTC (rev 5949) @@ -168,7 +168,7 @@ string name = entry.Key; ParamLocationRecognizer.NamedParameterDescription description = entry.Value; namedParamDescriptorMap[name] = - new NamedParameterDescriptor(name, null, description.BuildPositionsArray(), description.JpaStyle); + new NamedParameterDescriptor(name, null, description.JpaStyle); } return new ParameterMetadata(ordinalDescriptors, namedParamDescriptorMap); Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Loader/QueryLoader.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Loader/QueryLoader.cs 2011-06-18 13:14:46 UTC (rev 5948) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Loader/QueryLoader.cs 2011-06-18 13:30:39 UTC (rev 5949) @@ -137,16 +137,6 @@ } /// <summary> - /// Returns the locations of all occurrences of the named parameter. - /// </summary> - /// <param name="name"></param> - /// <returns></returns> - public override int[] GetNamedParameterLocs(string name) - { - return _queryTranslator.GetParameterTranslations().GetNamedParameterSqlLocations(name); - } - - /// <summary> /// /// </summary> /// <param name="lockModes">a collection of lock modes specified dynamically via the Query interface</param> Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QueryTranslatorImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QueryTranslatorImpl.cs 2011-06-18 13:14:46 UTC (rev 5948) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QueryTranslatorImpl.cs 2011-06-18 13:30:39 UTC (rev 5949) @@ -200,8 +200,7 @@ foreach (var name in parameterTranslations.GetNamedParameterNames()) { namedDescriptorMap[name] = - new NamedParameterDescriptor(name, parameterTranslations.GetNamedParameterExpectedType(name), - parameterTranslations.GetNamedParameterSqlLocations(name), false);// description.JpaStyle); + new NamedParameterDescriptor(name, parameterTranslations.GetNamedParameterExpectedType(name), false);// description.JpaStyle); } Modified: trunk/nhibernate/src/NHibernate/Hql/Classic/QueryTranslator.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Classic/QueryTranslator.cs 2011-06-18 13:14:46 UTC (rev 5948) +++ trunk/nhibernate/src/NHibernate/Hql/Classic/QueryTranslator.cs 2011-06-18 13:30:39 UTC (rev 5949) @@ -448,8 +448,7 @@ string name = entry.Key; ParamLocationRecognizer.NamedParameterDescription description = entry.Value; namedParamDescriptorMap[name] = - new NamedParameterDescriptor(name, parameterTranslations.GetNamedParameterExpectedType(name), - description.BuildPositionsArray(), description.JpaStyle); + new NamedParameterDescriptor(name, parameterTranslations.GetNamedParameterExpectedType(name), description.JpaStyle); } return new ParameterMetadata(ordinalParamDescriptors, namedParamDescriptorMap); @@ -794,18 +793,6 @@ } } - public override int[] GetNamedParameterLocs(string name) - { - List<int> o; - if (!namedParameters.TryGetValue(name, out o)) - { - QueryException qe = new QueryException("Named parameter does not appear in Query: " + name); - qe.QueryString = queryString; - throw qe; - } - return o.ToArray(); - } - public static string ScalarName(int x, int y) { return new StringBuilder() @@ -1834,7 +1821,7 @@ public int[] GetNamedParameterSqlLocations(string name) { - return queryTraslator.GetNamedParameterLocs(name); + return new int[0]; } public IType GetNamedParameterExpectedType(string name) Modified: trunk/nhibernate/src/NHibernate/Linq/Visitors/HqlGeneratorExpressionTreeVisitor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/Visitors/HqlGeneratorExpressionTreeVisitor.cs 2011-06-18 13:14:46 UTC (rev 5948) +++ trunk/nhibernate/src/NHibernate/Linq/Visitors/HqlGeneratorExpressionTreeVisitor.cs 2011-06-18 13:30:39 UTC (rev 5949) @@ -332,7 +332,7 @@ NamedParameter namedParameter; if (_parameters.ConstantToParameterMap.TryGetValue(operandEx, out namedParameter)) { - _parameters.RequiredHqlParameters.Add(new NamedParameterDescriptor(namedParameter.Name, null, new[] { _parameters.RequiredHqlParameters.Count + 1 }, false)); + _parameters.RequiredHqlParameters.Add(new NamedParameterDescriptor(namedParameter.Name, null, false)); return _hqlTreeBuilder.Parameter(namedParameter.Name).AsExpression(); } @@ -402,7 +402,7 @@ if (_parameters.ConstantToParameterMap.TryGetValue(expression, out namedParameter)) { - _parameters.RequiredHqlParameters.Add(new NamedParameterDescriptor(namedParameter.Name, null, new[] { _parameters.RequiredHqlParameters.Count + 1 }, false)); + _parameters.RequiredHqlParameters.Add(new NamedParameterDescriptor(namedParameter.Name, null, false)); if (namedParameter.Value is bool) { Modified: trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/ProcessSkip.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/ProcessSkip.cs 2011-06-18 13:14:46 UTC (rev 5948) +++ trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/ProcessSkip.cs 2011-06-18 13:30:39 UTC (rev 5949) @@ -16,7 +16,7 @@ if (parameters.ConstantToParameterMap.TryGetValue(resultOperator.Count as ConstantExpression, out namedParameter)) { - parameters.RequiredHqlParameters.Add(new NamedParameterDescriptor(namedParameter.Name, null, new[] {parameters.RequiredHqlParameters.Count + 1}, false)); + parameters.RequiredHqlParameters.Add(new NamedParameterDescriptor(namedParameter.Name, null, false)); tree.AddSkipClause(tree.TreeBuilder.Parameter(namedParameter.Name)); } else Modified: trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/ProcessTake.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/ProcessTake.cs 2011-06-18 13:14:46 UTC (rev 5948) +++ trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/ProcessTake.cs 2011-06-18 13:30:39 UTC (rev 5949) @@ -16,7 +16,7 @@ if (parameters.ConstantToParameterMap.TryGetValue(resultOperator.Count as ConstantExpression, out namedParameter)) { - parameters.RequiredHqlParameters.Add(new NamedParameterDescriptor(namedParameter.Name, null, new[] {parameters.RequiredHqlParameters.Count + 1}, false)); + parameters.RequiredHqlParameters.Add(new NamedParameterDescriptor(namedParameter.Name, null, false)); tree.AddTakeClause(tree.TreeBuilder.Parameter(namedParameter.Name)); } else Modified: trunk/nhibernate/src/NHibernate/Loader/Collection/SubselectCollectionLoader.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Loader/Collection/SubselectCollectionLoader.cs 2011-06-18 13:14:46 UTC (rev 5948) +++ trunk/nhibernate/src/NHibernate/Loader/Collection/SubselectCollectionLoader.cs 2011-06-18 13:30:39 UTC (rev 5949) @@ -52,11 +52,6 @@ LoadCollectionSubselect(session, keys, values, types, namedParameters, KeyType); } - public override int[] GetNamedParameterLocs(string name) - { - return new int[0]; - } - protected override IEnumerable<IParameterSpecification> GetParameterSpecifications() { return parametersSpecifications; Modified: trunk/nhibernate/src/NHibernate/Loader/Collection/SubselectOneToManyLoader.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Loader/Collection/SubselectOneToManyLoader.cs 2011-06-18 13:14:46 UTC (rev 5948) +++ trunk/nhibernate/src/NHibernate/Loader/Collection/SubselectOneToManyLoader.cs 2011-06-18 13:30:39 UTC (rev 5949) @@ -54,11 +54,6 @@ LoadCollectionSubselect(session, keys, values, types, namedParameters, KeyType); } - public override int[] GetNamedParameterLocs(string name) - { - return new int[0]; - } - protected override IEnumerable<IParameterSpecification> GetParameterSpecifications() { return parametersSpecifications; Modified: trunk/nhibernate/src/NHibernate/Loader/Criteria/CriteriaLoader.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Loader/Criteria/CriteriaLoader.cs 2011-06-18 13:14:46 UTC (rev 5948) +++ trunk/nhibernate/src/NHibernate/Loader/Criteria/CriteriaLoader.cs 2011-06-18 13:30:39 UTC (rev 5949) @@ -186,10 +186,5 @@ { return translator.CollectedParameterSpecifications; } - - public override int[] GetNamedParameterLocs(string name) - { - return new int[0]; - } } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Loader/Custom/CustomLoader.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Loader/Custom/CustomLoader.cs 2011-06-18 13:14:46 UTC (rev 5948) +++ trunk/nhibernate/src/NHibernate/Loader/Custom/CustomLoader.cs 2011-06-18 13:30:39 UTC (rev 5949) @@ -308,24 +308,6 @@ } } - public override int[] GetNamedParameterLocs(string name) - { - object loc = namedParameterBindPoints[name]; - if (loc == null) - { - throw new QueryException("Named parameter does not appear in Query: " + name, sql.ToString()); - } - - if (loc is int) - { - return new int[] {(int) loc}; - } - else - { - return ArrayHelper.ToIntArray((IList) loc); - } - } - protected override void AutoDiscoverTypes(IDataReader rs) { MetaData metadata = new MetaData(rs); Modified: trunk/nhibernate/src/NHibernate/Loader/Loader.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Loader/Loader.cs 2011-06-18 13:14:46 UTC (rev 5948) +++ trunk/nhibernate/src/NHibernate/Loader/Loader.cs 2011-06-18 13:30:39 UTC (rev 5949) @@ -1186,11 +1186,6 @@ //} } - public virtual int[] GetNamedParameterLocs(string name) - { - throw new AssertionFailure("no named parameters"); - } - /// <summary> /// Fetch a <c>IDbCommand</c>, call <c>SetMaxRows</c> and then execute it, /// advance to the first result and return an SQL <c>IDataReader</c> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2011-06-18 13:14:52
|
Revision: 5948 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5948&view=rev Author: fabiomaulo Date: 2011-06-18 13:14:46 +0000 (Sat, 18 Jun 2011) Log Message: ----------- Removed no more needed code Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Engine/SubselectFetch.cs trunk/nhibernate/src/NHibernate/Loader/Collection/CollectionLoader.cs trunk/nhibernate/src/NHibernate/Loader/Collection/SubselectCollectionLoader.cs trunk/nhibernate/src/NHibernate/Loader/Collection/SubselectOneToManyLoader.cs trunk/nhibernate/src/NHibernate/Loader/Loader.cs trunk/nhibernate/src/NHibernate/Persister/Collection/BasicCollectionPersister.cs trunk/nhibernate/src/NHibernate/Persister/Collection/OneToManyPersister.cs Modified: trunk/nhibernate/src/NHibernate/Engine/SubselectFetch.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Engine/SubselectFetch.cs 2011-06-18 12:59:25 UTC (rev 5947) +++ trunk/nhibernate/src/NHibernate/Engine/SubselectFetch.cs 2011-06-18 13:14:46 UTC (rev 5948) @@ -1,4 +1,3 @@ -using System.Collections.Generic; using Iesi.Collections.Generic; using NHibernate.Persister.Entity; using NHibernate.SqlCommand; @@ -10,17 +9,15 @@ { private readonly string alias; private readonly ILoadable loadable; - private readonly IDictionary<string, int[]> namedParameterLocMap; private readonly QueryParameters queryParameters; private readonly SqlString queryString; private readonly ISet<EntityKey> resultingEntityKeys; public SubselectFetch(string alias, ILoadable loadable, QueryParameters queryParameters, - ISet<EntityKey> resultingEntityKeys, IDictionary<string, int[]> namedParameterLocMap) + ISet<EntityKey> resultingEntityKeys) { this.resultingEntityKeys = resultingEntityKeys; this.queryParameters = queryParameters; - this.namedParameterLocMap = namedParameterLocMap; this.loadable = loadable; this.alias = alias; @@ -37,11 +34,6 @@ get { return resultingEntityKeys; } } - public IDictionary<string, int[]> NamedParameterLocMap - { - get { return namedParameterLocMap; } - } - public SqlString ToSubselectString(string ukname) { string[] joinColumns = ukname == null Modified: trunk/nhibernate/src/NHibernate/Loader/Collection/CollectionLoader.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Loader/Collection/CollectionLoader.cs 2011-06-18 12:59:25 UTC (rev 5947) +++ trunk/nhibernate/src/NHibernate/Loader/Collection/CollectionLoader.cs 2011-06-18 13:14:46 UTC (rev 5948) @@ -68,7 +68,7 @@ return parametersSpecifications ?? (parametersSpecifications = CreateParameterSpecificationsAndAssignBackTrack(SqlString.GetParameters()).ToArray()); } - protected SqlString GetSubSelectWithLimits(SqlString subquery, ICollection<IParameterSpecification> parameterSpecs, RowSelection processedRowSelection, IDictionary<string, TypedValue> parameters, IDictionary<string, int[]> namedParameterLocMap) + protected SqlString GetSubSelectWithLimits(SqlString subquery, ICollection<IParameterSpecification> parameterSpecs, RowSelection processedRowSelection, IDictionary<string, TypedValue> parameters) { ISessionFactoryImplementor sessionFactory = Factory; Dialect.Dialect dialect = sessionFactory.Dialect; @@ -92,7 +92,6 @@ skipSqlParameter = Parameter.Placeholder; skipSqlParameter.BackTrack = skipParameter.GetIdsForBackTrack(sessionFactory).First(); parameters.Add(skipParameterName, new TypedValue(skipParameter.ExpectedType, skip.Value, EntityMode.Poco)); - namedParameterLocMap.Add(skipParameterName, new int[0]); parameterSpecs.Add(skipParameter); } if (take.HasValue) @@ -102,7 +101,6 @@ takeSqlParameter = Parameter.Placeholder; takeSqlParameter.BackTrack = takeParameter.GetIdsForBackTrack(sessionFactory).First(); parameters.Add(takeParameterName, new TypedValue(takeParameter.ExpectedType, take.Value, EntityMode.Poco)); - namedParameterLocMap.Add(takeParameterName, new int[0]); parameterSpecs.Add(takeParameter); } // The dialect can move the given parameters where he need, what it can't do is generates new parameters loosing the BackTrack. Modified: trunk/nhibernate/src/NHibernate/Loader/Collection/SubselectCollectionLoader.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Loader/Collection/SubselectCollectionLoader.cs 2011-06-18 12:59:25 UTC (rev 5947) +++ trunk/nhibernate/src/NHibernate/Loader/Collection/SubselectCollectionLoader.cs 2011-06-18 13:14:46 UTC (rev 5948) @@ -13,14 +13,13 @@ { private const int BatchSizeForSubselectFetching = 1; private readonly object[] keys; - private readonly IDictionary<string, int[]> namedParameterLocMap; private readonly IDictionary<string, TypedValue> namedParameters; private readonly IType[] types; private readonly object[] values; private readonly List<IParameterSpecification> parametersSpecifications; public SubselectCollectionLoader(IQueryableCollection persister, SqlString subquery, ICollection<EntityKey> entityKeys, - QueryParameters queryParameters, IDictionary<string, int[]> namedParameterLocMap, + QueryParameters queryParameters, ISessionFactoryImplementor factory, IDictionary<string, IFilter> enabledFilters) : base(persister, BatchSizeForSubselectFetching, factory, enabledFilters) { @@ -33,7 +32,6 @@ // NH Different behavior: to deal with positionslParameter+NamedParameter+ParameterOfFilters namedParameters = new Dictionary<string, TypedValue>(queryParameters.NamedParameters); - this.namedParameterLocMap = new Dictionary<string, int[]>(namedParameterLocMap); parametersSpecifications = queryParameters.ProcessedSqlParameters.ToList(); var processedRowSelection = queryParameters.ProcessedRowSelection; SqlString finalSubquery = subquery; @@ -41,7 +39,7 @@ { // when the original query has an "ORDER BY" we can't re-apply the pagination // this is a simplification, we should actually check which is the "ORDER BY" clause because when the "ORDER BY" is just for the PK we can re-apply "ORDER BY" and pagination. - finalSubquery = GetSubSelectWithLimits(subquery, parametersSpecifications, processedRowSelection, namedParameters, this.namedParameterLocMap); + finalSubquery = GetSubSelectWithLimits(subquery, parametersSpecifications, processedRowSelection, namedParameters); } InitializeFromWalker(persister, finalSubquery, BatchSizeForSubselectFetching, enabledFilters, factory); @@ -56,7 +54,7 @@ public override int[] GetNamedParameterLocs(string name) { - return namedParameterLocMap[name]; + return new int[0]; } protected override IEnumerable<IParameterSpecification> GetParameterSpecifications() Modified: trunk/nhibernate/src/NHibernate/Loader/Collection/SubselectOneToManyLoader.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Loader/Collection/SubselectOneToManyLoader.cs 2011-06-18 12:59:25 UTC (rev 5947) +++ trunk/nhibernate/src/NHibernate/Loader/Collection/SubselectOneToManyLoader.cs 2011-06-18 13:14:46 UTC (rev 5948) @@ -15,14 +15,13 @@ { private const int BatchSizeForSubselectFetching = 1; private readonly object[] keys; - private readonly IDictionary<string, int[]> namedParameterLocMap; private readonly IDictionary<string, TypedValue> namedParameters; private readonly IType[] types; private readonly object[] values; private readonly List<IParameterSpecification> parametersSpecifications; public SubselectOneToManyLoader(IQueryableCollection persister, SqlString subquery, ICollection<EntityKey> entityKeys, - QueryParameters queryParameters, IDictionary<string, int[]> namedParameterLocMap, + QueryParameters queryParameters, ISessionFactoryImplementor factory, IDictionary<string, IFilter> enabledFilters) : base(persister, BatchSizeForSubselectFetching, factory, enabledFilters) { @@ -35,7 +34,6 @@ // NH Different behavior: to deal with positionslParameter+NamedParameter+ParameterOfFilters namedParameters = new Dictionary<string, TypedValue>(queryParameters.NamedParameters); - this.namedParameterLocMap = new Dictionary<string, int[]>(namedParameterLocMap); parametersSpecifications = queryParameters.ProcessedSqlParameters.ToList(); var processedRowSelection = queryParameters.ProcessedRowSelection; SqlString finalSubquery = subquery; @@ -43,7 +41,7 @@ { // when the original query has an "ORDER BY" we can't re-apply the pagination. // This is a simplification, we should actually check which is the "ORDER BY" clause because when the "ORDER BY" is just for the PK we can re-apply "ORDER BY" and pagination. - finalSubquery = GetSubSelectWithLimits(subquery, parametersSpecifications, processedRowSelection, namedParameters, this.namedParameterLocMap); + finalSubquery = GetSubSelectWithLimits(subquery, parametersSpecifications, processedRowSelection, namedParameters); } InitializeFromWalker(persister, finalSubquery, BatchSizeForSubselectFetching, enabledFilters, factory); @@ -58,7 +56,7 @@ public override int[] GetNamedParameterLocs(string name) { - return namedParameterLocMap[name]; + return new int[0]; } protected override IEnumerable<IParameterSpecification> GetParameterSpecifications() Modified: trunk/nhibernate/src/NHibernate/Loader/Loader.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Loader/Loader.cs 2011-06-18 12:59:25 UTC (rev 5947) +++ trunk/nhibernate/src/NHibernate/Loader/Loader.cs 2011-06-18 13:14:46 UTC (rev 5948) @@ -521,8 +521,6 @@ ISet<EntityKey>[] keySets = Transpose(keys); - IDictionary<string, int[]> namedParameterLocMap = BuildNamedParameterLocMap(queryParameters); - ILoadable[] loadables = EntityPersisters; string[] aliases = Aliases; @@ -533,7 +531,7 @@ if (rowKeys[i] != null && loadables[i].HasSubselectLoadableCollections) { SubselectFetch subselectFetch = - new SubselectFetch(aliases[i], loadables[i], queryParameters, keySets[i], namedParameterLocMap); + new SubselectFetch(aliases[i], loadables[i], queryParameters, keySets[i]); session.PersistenceContext.BatchFetchQueue.AddSubselect(rowKeys[i], subselectFetch); } @@ -542,23 +540,6 @@ } } - private IDictionary<string, int[]> BuildNamedParameterLocMap(QueryParameters queryParameters) - { - if (queryParameters.NamedParameters != null) - { - IDictionary<string, int[]> namedParameterLocMap = new Dictionary<string, int[]>(); - foreach (string name in queryParameters.NamedParameters.Keys) - { - namedParameterLocMap[name] = GetNamedParameterLocs(name); - } - return namedParameterLocMap; - } - else - { - return null; - } - } - internal void InitializeEntitiesAndCollections(IList hydratedObjects, object resultSetId, ISessionImplementor session, bool readOnly) { ICollectionPersister[] collectionPersisters = CollectionPersisters; Modified: trunk/nhibernate/src/NHibernate/Persister/Collection/BasicCollectionPersister.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Persister/Collection/BasicCollectionPersister.cs 2011-06-18 12:59:25 UTC (rev 5947) +++ trunk/nhibernate/src/NHibernate/Persister/Collection/BasicCollectionPersister.cs 2011-06-18 13:14:46 UTC (rev 5948) @@ -300,7 +300,7 @@ { return new SubselectCollectionLoader(this, subselect.ToSubselectString(CollectionType.LHSPropertyName), subselect.Result, - subselect.QueryParameters, subselect.NamedParameterLocMap, session.Factory, + subselect.QueryParameters, session.Factory, session.EnabledFilters); } Modified: trunk/nhibernate/src/NHibernate/Persister/Collection/OneToManyPersister.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Persister/Collection/OneToManyPersister.cs 2011-06-18 12:59:25 UTC (rev 5947) +++ trunk/nhibernate/src/NHibernate/Persister/Collection/OneToManyPersister.cs 2011-06-18 13:14:46 UTC (rev 5948) @@ -382,7 +382,7 @@ { return new SubselectOneToManyLoader(this, subselect.ToSubselectString(CollectionType.LHSPropertyName), subselect.Result, - subselect.QueryParameters, subselect.NamedParameterLocMap, session.Factory, + subselect.QueryParameters, session.Factory, session.EnabledFilters); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2011-06-18 12:59:32
|
Revision: 5947 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5947&view=rev Author: fabiomaulo Date: 2011-06-18 12:59:25 +0000 (Sat, 18 Jun 2011) Log Message: ----------- Fix NH-2296 Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Engine/QueryParameters.cs trunk/nhibernate/src/NHibernate/Loader/Collection/BasicCollectionLoader.cs trunk/nhibernate/src/NHibernate/Loader/Collection/CollectionLoader.cs trunk/nhibernate/src/NHibernate/Loader/Collection/OneToManyLoader.cs trunk/nhibernate/src/NHibernate/Loader/Collection/SubselectCollectionLoader.cs trunk/nhibernate/src/NHibernate/Loader/Collection/SubselectOneToManyLoader.cs trunk/nhibernate/src/NHibernate/Loader/Loader.cs trunk/nhibernate/src/NHibernate/SqlCommand/SubselectClauseExtractor.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj trunk/nhibernate/src/NHibernate.Test/SubselectFetchTest/ParentChild.hbm.xml Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2296/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2296/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2296/Mappings.hbm.xml trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2296/Model.cs Modified: trunk/nhibernate/src/NHibernate/Engine/QueryParameters.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Engine/QueryParameters.cs 2011-06-17 18:09:19 UTC (rev 5946) +++ trunk/nhibernate/src/NHibernate/Engine/QueryParameters.cs 2011-06-18 12:59:25 UTC (rev 5947) @@ -157,8 +157,8 @@ } public SqlString ProcessedSql { get; internal set; } - public IEnumerable<IParameterSpecification> ProcessedSqlParameters { get; internal set; } + public RowSelection ProcessedRowSelection { get; internal set; } public bool NaturalKeyLookup { get; set; } Modified: trunk/nhibernate/src/NHibernate/Loader/Collection/BasicCollectionLoader.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Loader/Collection/BasicCollectionLoader.cs 2011-06-17 18:09:19 UTC (rev 5946) +++ trunk/nhibernate/src/NHibernate/Loader/Collection/BasicCollectionLoader.cs 2011-06-18 12:59:25 UTC (rev 5947) @@ -30,6 +30,11 @@ ISessionFactoryImplementor factory, IDictionary<string, IFilter> enabledFilters) : base(collectionPersister, factory, enabledFilters) { + InitializeFromWalker(collectionPersister, subquery, batchSize, enabledFilters, factory); + } + + protected virtual void InitializeFromWalker(IQueryableCollection collectionPersister, SqlString subquery, int batchSize, IDictionary<string, IFilter> enabledFilters, ISessionFactoryImplementor factory) + { JoinWalker walker = new BasicCollectionJoinWalker(collectionPersister, batchSize, subquery, factory, enabledFilters); InitFromWalker(walker); Modified: trunk/nhibernate/src/NHibernate/Loader/Collection/CollectionLoader.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Loader/Collection/CollectionLoader.cs 2011-06-17 18:09:19 UTC (rev 5946) +++ trunk/nhibernate/src/NHibernate/Loader/Collection/CollectionLoader.cs 2011-06-18 12:59:25 UTC (rev 5947) @@ -67,5 +67,48 @@ { return parametersSpecifications ?? (parametersSpecifications = CreateParameterSpecificationsAndAssignBackTrack(SqlString.GetParameters()).ToArray()); } + + protected SqlString GetSubSelectWithLimits(SqlString subquery, ICollection<IParameterSpecification> parameterSpecs, RowSelection processedRowSelection, IDictionary<string, TypedValue> parameters, IDictionary<string, int[]> namedParameterLocMap) + { + ISessionFactoryImplementor sessionFactory = Factory; + Dialect.Dialect dialect = sessionFactory.Dialect; + + RowSelection selection = processedRowSelection; + bool useLimit = UseLimit(selection, dialect); + if (useLimit) + { + bool hasFirstRow = GetFirstRow(selection) > 0; + bool useOffset = hasFirstRow && dialect.SupportsLimitOffset; + int max = GetMaxOrLimit(dialect, selection); + int? skip = useOffset ? (int?) dialect.GetOffsetValue(GetFirstRow(selection)) : null; + int? take = max != int.MaxValue ? (int?) max : null; + + Parameter skipSqlParameter = null; + Parameter takeSqlParameter = null; + if (skip.HasValue) + { + string skipParameterName = "nhsubselectskip"; + var skipParameter = new NamedParameterSpecification(1, 0, skipParameterName) {ExpectedType = NHibernateUtil.Int32}; + skipSqlParameter = Parameter.Placeholder; + skipSqlParameter.BackTrack = skipParameter.GetIdsForBackTrack(sessionFactory).First(); + parameters.Add(skipParameterName, new TypedValue(skipParameter.ExpectedType, skip.Value, EntityMode.Poco)); + namedParameterLocMap.Add(skipParameterName, new int[0]); + parameterSpecs.Add(skipParameter); + } + if (take.HasValue) + { + string takeParameterName = "nhsubselecttake"; + var takeParameter = new NamedParameterSpecification(1, 0, takeParameterName) {ExpectedType = NHibernateUtil.Int32}; + takeSqlParameter = Parameter.Placeholder; + takeSqlParameter.BackTrack = takeParameter.GetIdsForBackTrack(sessionFactory).First(); + parameters.Add(takeParameterName, new TypedValue(takeParameter.ExpectedType, take.Value, EntityMode.Poco)); + namedParameterLocMap.Add(takeParameterName, new int[0]); + parameterSpecs.Add(takeParameter); + } + // The dialect can move the given parameters where he need, what it can't do is generates new parameters loosing the BackTrack. + return dialect.GetLimitString(subquery, skip, take, skipSqlParameter, takeSqlParameter); + } + return subquery; + } } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Loader/Collection/OneToManyLoader.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Loader/Collection/OneToManyLoader.cs 2011-06-17 18:09:19 UTC (rev 5946) +++ trunk/nhibernate/src/NHibernate/Loader/Collection/OneToManyLoader.cs 2011-06-18 12:59:25 UTC (rev 5947) @@ -30,6 +30,11 @@ ISessionFactoryImplementor factory, IDictionary<string, IFilter> enabledFilters) : base(oneToManyPersister, factory, enabledFilters) { + InitializeFromWalker(oneToManyPersister, subquery, batchSize, enabledFilters, factory); + } + + protected virtual void InitializeFromWalker(IQueryableCollection oneToManyPersister, SqlString subquery, int batchSize, IDictionary<string, IFilter> enabledFilters, ISessionFactoryImplementor factory) + { JoinWalker walker = new OneToManyJoinWalker(oneToManyPersister, batchSize, subquery, factory, enabledFilters); InitFromWalker(walker); Modified: trunk/nhibernate/src/NHibernate/Loader/Collection/SubselectCollectionLoader.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Loader/Collection/SubselectCollectionLoader.cs 2011-06-17 18:09:19 UTC (rev 5946) +++ trunk/nhibernate/src/NHibernate/Loader/Collection/SubselectCollectionLoader.cs 2011-06-18 12:59:25 UTC (rev 5947) @@ -11,6 +11,7 @@ /// <summary> Implements subselect fetching for a collection</summary> public class SubselectCollectionLoader : BasicCollectionLoader { + private const int BatchSizeForSubselectFetching = 1; private readonly object[] keys; private readonly IDictionary<string, int[]> namedParameterLocMap; private readonly IDictionary<string, TypedValue> namedParameters; @@ -21,7 +22,7 @@ public SubselectCollectionLoader(IQueryableCollection persister, SqlString subquery, ICollection<EntityKey> entityKeys, QueryParameters queryParameters, IDictionary<string, int[]> namedParameterLocMap, ISessionFactoryImplementor factory, IDictionary<string, IFilter> enabledFilters) - : base(persister, 1, subquery, factory, enabledFilters) + : base(persister, BatchSizeForSubselectFetching, factory, enabledFilters) { keys = new object[entityKeys.Count]; int i = 0; @@ -29,13 +30,23 @@ { keys[i++] = entityKey.Identifier; } - + // NH Different behavior: to deal with positionslParameter+NamedParameter+ParameterOfFilters + namedParameters = new Dictionary<string, TypedValue>(queryParameters.NamedParameters); + this.namedParameterLocMap = new Dictionary<string, int[]>(namedParameterLocMap); parametersSpecifications = queryParameters.ProcessedSqlParameters.ToList(); - namedParameters = queryParameters.NamedParameters; + var processedRowSelection = queryParameters.ProcessedRowSelection; + SqlString finalSubquery = subquery; + if (queryParameters.ProcessedRowSelection != null && !SubselectClauseExtractor.HasOrderBy(queryParameters.ProcessedSql)) + { + // when the original query has an "ORDER BY" we can't re-apply the pagination + // this is a simplification, we should actually check which is the "ORDER BY" clause because when the "ORDER BY" is just for the PK we can re-apply "ORDER BY" and pagination. + finalSubquery = GetSubSelectWithLimits(subquery, parametersSpecifications, processedRowSelection, namedParameters, this.namedParameterLocMap); + } + InitializeFromWalker(persister, finalSubquery, BatchSizeForSubselectFetching, enabledFilters, factory); + types = queryParameters.PositionalParameterTypes; values = queryParameters.PositionalParameterValues; - this.namedParameterLocMap = namedParameterLocMap; } public override void Initialize(object id, ISessionImplementor session) Modified: trunk/nhibernate/src/NHibernate/Loader/Collection/SubselectOneToManyLoader.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Loader/Collection/SubselectOneToManyLoader.cs 2011-06-17 18:09:19 UTC (rev 5946) +++ trunk/nhibernate/src/NHibernate/Loader/Collection/SubselectOneToManyLoader.cs 2011-06-18 12:59:25 UTC (rev 5947) @@ -5,7 +5,6 @@ using NHibernate.Persister.Collection; using NHibernate.SqlCommand; using NHibernate.Type; -using NHibernate.Util; namespace NHibernate.Loader.Collection { @@ -14,6 +13,7 @@ /// </summary> public class SubselectOneToManyLoader : OneToManyLoader { + private const int BatchSizeForSubselectFetching = 1; private readonly object[] keys; private readonly IDictionary<string, int[]> namedParameterLocMap; private readonly IDictionary<string, TypedValue> namedParameters; @@ -24,7 +24,7 @@ public SubselectOneToManyLoader(IQueryableCollection persister, SqlString subquery, ICollection<EntityKey> entityKeys, QueryParameters queryParameters, IDictionary<string, int[]> namedParameterLocMap, ISessionFactoryImplementor factory, IDictionary<string, IFilter> enabledFilters) - : base(persister, 1, subquery, factory, enabledFilters) + : base(persister, BatchSizeForSubselectFetching, factory, enabledFilters) { keys = new object[entityKeys.Count]; int i = 0; @@ -34,11 +34,21 @@ } // NH Different behavior: to deal with positionslParameter+NamedParameter+ParameterOfFilters + namedParameters = new Dictionary<string, TypedValue>(queryParameters.NamedParameters); + this.namedParameterLocMap = new Dictionary<string, int[]>(namedParameterLocMap); parametersSpecifications = queryParameters.ProcessedSqlParameters.ToList(); - namedParameters = queryParameters.NamedParameters; + var processedRowSelection = queryParameters.ProcessedRowSelection; + SqlString finalSubquery = subquery; + if (queryParameters.ProcessedRowSelection != null && !SubselectClauseExtractor.HasOrderBy(queryParameters.ProcessedSql)) + { + // when the original query has an "ORDER BY" we can't re-apply the pagination. + // This is a simplification, we should actually check which is the "ORDER BY" clause because when the "ORDER BY" is just for the PK we can re-apply "ORDER BY" and pagination. + finalSubquery = GetSubSelectWithLimits(subquery, parametersSpecifications, processedRowSelection, namedParameters, this.namedParameterLocMap); + } + InitializeFromWalker(persister, finalSubquery, BatchSizeForSubselectFetching, enabledFilters, factory); + types = queryParameters.PositionalParameterTypes; values = queryParameters.PositionalParameterValues; - this.namedParameterLocMap = namedParameterLocMap; } public override void Initialize(object id, ISessionImplementor session) Modified: trunk/nhibernate/src/NHibernate/Loader/Loader.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Loader/Loader.cs 2011-06-17 18:09:19 UTC (rev 5946) +++ trunk/nhibernate/src/NHibernate/Loader/Loader.cs 2011-06-18 12:59:25 UTC (rev 5947) @@ -1647,10 +1647,10 @@ // dynamic-filter parameters: during the createion of the SqlString of allLoader implementation, filters can be added as SQL_TOKEN/string for this reason we have to re-parse the SQL. sqlString = ExpandDynamicFilterParameters(sqlString, parameterSpecs, session); - AdjustQueryParametersForSubSelectFetching(sqlString, parameterSpecs, queryParameters); // NOTE: see TODO below + AdjustQueryParametersForSubSelectFetching(sqlString, parameterSpecs, queryParameters); + // Add limits sqlString = AddLimitsParametersIfNeeded(sqlString, parameterSpecs, queryParameters, session); - // TODO: for sub-select fetching we have to try to assign the QueryParameter.ProcessedSQL here (with limits) but only after use IParameterSpecification for any kind of queries and taking care about the work done by SubselectClauseExtractor // The PreprocessSQL method can modify the SqlString but should never add parameters (or we have to override it) sqlString = PreprocessSQL(sqlString, queryParameters, session.Factory.Dialect); @@ -1668,10 +1668,14 @@ protected abstract IEnumerable<IParameterSpecification> GetParameterSpecifications(); - protected void AdjustQueryParametersForSubSelectFetching(SqlString sqlString, IEnumerable<IParameterSpecification> parameterSpecs, QueryParameters queryParameters) + protected void AdjustQueryParametersForSubSelectFetching(SqlString filteredSqlString, IEnumerable<IParameterSpecification> parameterSpecsWithFilters, QueryParameters queryParameters) { - queryParameters.ProcessedSql = sqlString; - queryParameters.ProcessedSqlParameters = parameterSpecs.ToList(); + queryParameters.ProcessedSql = filteredSqlString; + queryParameters.ProcessedSqlParameters = parameterSpecsWithFilters.ToList(); + if (queryParameters.RowSelection != null) + { + queryParameters.ProcessedRowSelection = new RowSelection { FirstRow = queryParameters.RowSelection.FirstRow, MaxRows = queryParameters.RowSelection.MaxRows }; + } } protected SqlString ExpandDynamicFilterParameters(SqlString sqlString, ICollection<IParameterSpecification> parameterSpecs, ISessionImplementor session) Modified: trunk/nhibernate/src/NHibernate/SqlCommand/SubselectClauseExtractor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/SqlCommand/SubselectClauseExtractor.cs 2011-06-17 18:09:19 UTC (rev 5946) +++ trunk/nhibernate/src/NHibernate/SqlCommand/SubselectClauseExtractor.cs 2011-06-18 12:59:25 UTC (rev 5947) @@ -11,6 +11,11 @@ /// </summary> public class SubselectClauseExtractor { + /* + * NH TODO: this implementation will break, for MsSQL2005Dialect, a when the query is an HQL with skip/take because the last "ORDER BY" is there for pagination. + * Because HQL skip/take are new features, we hope nobody will use it in conjuction with subselect fetching at least until MS-SQL will release a more modern + * syntax for pagination. + */ private const string FromClauseToken = " from "; private const string OrderByToken = "order by"; @@ -94,6 +99,13 @@ return builder.ToSqlString(); } + public static bool HasOrderBy(SqlString subselect) + { + var extractor = new SubselectClauseExtractor((object[])subselect.Parts); + extractor.GetSqlString(); + return extractor.lastOrderByPartIndex >= 0; + } + private int FindFromClauseInPart(string part) { int afterLastClosingParenIndex = 0; Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2296/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2296/Fixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2296/Fixture.cs 2011-06-18 12:59:25 UTC (rev 5947) @@ -0,0 +1,67 @@ +using System.Linq; +using NUnit.Framework; +using SharpTestsEx; + +namespace NHibernate.Test.NHSpecificTest.NH2296 +{ + [TestFixture] + public class Fixture : BugTestCase + { + protected override void OnSetUp() + { + base.OnSetUp(); + + using (var s = OpenSession()) + using (var tx = s.BeginTransaction()) + { + var o = new Order() { AccountName = "Acct1" }; + o.Products.Add(new Product() { StatusReason = "Success", Order = o }); + o.Products.Add(new Product() { StatusReason = "Failure", Order = o }); + s.Save(o); + + o = new Order() { AccountName = "Acct2" }; + s.Save(o); + + o = new Order() { AccountName = "Acct3" }; + o.Products.Add(new Product() { StatusReason = "Success", Order = o }); + o.Products.Add(new Product() { StatusReason = "Failure", Order = o }); + s.Save(o); + + tx.Commit(); + } + } + + protected override void OnTearDown() + { + using (var s = OpenSession()) + using (var tx = s.BeginTransaction()) + { + s.Delete("from Product"); + s.Delete("from Order"); + tx.Commit(); + } + + base.OnTearDown(); + } + + [Test] + public void Test() + { + using (var s = OpenSession()) + using (var tx = s.BeginTransaction()) + { + var orders = s.CreateQuery("select o from Order o") + .SetMaxResults(2) + .List<Order>(); + + // trigger lazy-loading of products, using subselect fetch. + string sr = orders[0].Products[0].StatusReason; + + // count of entities we want: + int ourEntities = orders.Count + orders.Sum(o => o.Products.Count); + + s.Statistics.EntityCount.Should().Be(ourEntities); + } + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2296/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2296/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2296/Mappings.hbm.xml 2011-06-18 12:59:25 UTC (rev 5947) @@ -0,0 +1,48 @@ +<?xml version="1.0"?> +<hibernate-mapping + xmlns="urn:nhibernate-mapping-2.2" + default-access="property" + auto-import="true" + default-cascade="none" + default-lazy="true" + assembly="NHibernate.Test" + namespace="NHibernate.Test.NHSpecificTest.NH2296"> + + <class mutable="true" name="Order" table="`Order`"> + + <id name="Id" type="System.Int32"> + <column name="Id" /> + <generator class="identity" /> + </id> + + <bag cascade="all-delete-orphan" fetch="subselect" inverse="true" name="Products" mutable="true"> + <key> + <column name="Order_id" /> + </key> + <one-to-many class="Product" /> + </bag> + + <property name="AccountName" type="System.String"> + <column name="AccountName" /> + </property> + + </class> + + <class mutable="true" name="Product" table="`Product`"> + + <id name="Id" type="System.Int32"> + <column name="Id" /> + <generator class="identity" /> + </id> + + <property name="StatusReason" type="System.String"> + <column name="StatusReason" /> + </property> + + <many-to-one class="Order" name="Order"> + <column name="Order_id" /> + </many-to-one> + + </class> + +</hibernate-mapping> \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2296/Model.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2296/Model.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2296/Model.cs 2011-06-18 12:59:25 UTC (rev 5947) @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; + +namespace NHibernate.Test.NHSpecificTest.NH2296 +{ + public class Order + { + public virtual int Id { get; set; } + public virtual string AccountName { get; set; } + public virtual IList<Product> Products { get; set; } + + public Order() + { + this.Products = new List<Product>(); + } + } + + public class Product + { + public virtual int Id { get; set; } + public virtual string StatusReason { get; set; } + public virtual Order Order { get; set; } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2011-06-17 18:09:19 UTC (rev 5946) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2011-06-18 12:59:25 UTC (rev 5947) @@ -723,6 +723,8 @@ <Compile Include="NHSpecificTest\NH2288\Fixture.cs" /> <Compile Include="NHSpecificTest\NH2293\Fixture.cs" /> <Compile Include="NHSpecificTest\NH2294\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH2296\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH2296\Model.cs" /> <Compile Include="NHSpecificTest\NH2302\Fixture.cs" /> <Compile Include="NHSpecificTest\NH2302\StringLengthEntity.cs" /> <Compile Include="NHSpecificTest\NH2303\Fixture.cs" /> @@ -2716,6 +2718,7 @@ <EmbeddedResource Include="NHSpecificTest\NH1291AnonExample\Mappings.hbm.xml" /> </ItemGroup> <ItemGroup> + <EmbeddedResource Include="NHSpecificTest\NH2296\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH2760\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH2662\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH2703\Mappings.hbm.xml" /> Modified: trunk/nhibernate/src/NHibernate.Test/SubselectFetchTest/ParentChild.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/SubselectFetchTest/ParentChild.hbm.xml 2011-06-17 18:09:19 UTC (rev 5946) +++ trunk/nhibernate/src/NHibernate.Test/SubselectFetchTest/ParentChild.hbm.xml 2011-06-18 12:59:25 UTC (rev 5947) @@ -8,7 +8,7 @@ <generator class="assigned" /> </id> <bag name="Friends" fetch="subselect" table="ChildChild"> - <key column="childName1" /><!-- H3 has not-null="true" --> + <key column="childName1" not-null="true" /> <many-to-many class="Child" column="childName2"/> </bag> </class> @@ -18,12 +18,12 @@ <generator class="assigned" /> </id> <list name="Children" fetch="subselect" cascade="all"> - <key column="parentName" /><!-- H3 has not-null="true" --> + <key column="parentName" not-null="true"/> <index column="loc"/> <one-to-many class="Child"/> </list> <list name="MoreChildren" table="ParentChild" fetch="subselect"> - <key column="parentName" /><!-- H3 has not-null="true" --> + <key column="parentName" not-null="true"/> <index column="loc"/> <many-to-many class="Child" column="childName"/> </list> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2011-06-17 18:09:25
|
Revision: 5946 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5946&view=rev Author: fabiomaulo Date: 2011-06-17 18:09:19 +0000 (Fri, 17 Jun 2011) Log Message: ----------- Removed dead code Modified Paths: -------------- trunk/nhibernate/src/NHibernate/NHibernate.csproj Removed Paths: ------------- trunk/nhibernate/src/NHibernate/Engine/Query/QueryMetadata.cs Deleted: trunk/nhibernate/src/NHibernate/Engine/Query/QueryMetadata.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Engine/Query/QueryMetadata.cs 2011-06-17 17:43:54 UTC (rev 5945) +++ trunk/nhibernate/src/NHibernate/Engine/Query/QueryMetadata.cs 2011-06-17 18:09:19 UTC (rev 5946) @@ -1,56 +0,0 @@ -using System; -using Iesi.Collections.Generic; -using NHibernate.Type; - -namespace NHibernate.Engine.Query -{ - /// <summary> Defines metadata regarding a translated HQL or native-SQL query. </summary> - [Serializable] - public class QueryMetadata - { - private readonly string sourceQuery; - private readonly ParameterMetadata parameterMetadata; - private readonly string[] returnAliases; - private readonly IType[] returnTypes; - private readonly ISet<string> querySpaces; - - public QueryMetadata(string sourceQuery, ParameterMetadata parameterMetadata, - string[] returnAliases, IType[] returnTypes, ISet<string> querySpaces) - { - this.sourceQuery = sourceQuery; - this.parameterMetadata = parameterMetadata; - this.returnAliases = returnAliases; - this.returnTypes = returnTypes; - this.querySpaces = querySpaces; - } - - /// <summary> Get the source HQL or native-SQL query. </summary> - public string SourceQuery - { - get { return sourceQuery; } - } - - public ParameterMetadata ParameterMetadata - { - get { return parameterMetadata; } - } - - /// <summary> Return source query select clause aliases (if any) </summary> - public string[] ReturnAliases - { - get { return returnAliases; } - } - - /// <summary> An array of types describing the returns of the source query. </summary> - public IType[] ReturnTypes - { - get { return returnTypes; } - } - - /// <summary> The set of query spaces affected by this source query. </summary> - public ISet<string> QuerySpaces - { - get { return querySpaces; } - } - } -} Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj =================================================================== --- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2011-06-17 17:43:54 UTC (rev 5945) +++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2011-06-17 18:09:19 UTC (rev 5946) @@ -1293,7 +1293,6 @@ <Compile Include="Engine\Query\OrdinalParameterDescriptor.cs" /> <Compile Include="Engine\Query\ParameterMetadata.cs" /> <Compile Include="Engine\Query\ParamLocationRecognizer.cs" /> - <Compile Include="Engine\Query\QueryMetadata.cs" /> <Compile Include="Engine\Query\QueryPlanCache.cs" /> <Compile Include="Engine\Query\ReturnMetadata.cs" /> <Compile Include="Engine\Query\FilterQueryPlan.cs" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2011-06-17 17:44:00
|
Revision: 5945 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5945&view=rev Author: fabiomaulo Date: 2011-06-17 17:43:54 +0000 (Fri, 17 Jun 2011) Log Message: ----------- Refactoring (DRY) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Loader/QueryLoader.cs trunk/nhibernate/src/NHibernate/Hql/Classic/QueryTranslator.cs trunk/nhibernate/src/NHibernate/Loader/Collection/CollectionLoader.cs trunk/nhibernate/src/NHibernate/Loader/Collection/SubselectCollectionLoader.cs trunk/nhibernate/src/NHibernate/Loader/Collection/SubselectOneToManyLoader.cs trunk/nhibernate/src/NHibernate/Loader/Criteria/CriteriaLoader.cs trunk/nhibernate/src/NHibernate/Loader/Custom/CustomLoader.cs trunk/nhibernate/src/NHibernate/Loader/Entity/AbstractEntityLoader.cs trunk/nhibernate/src/NHibernate/Loader/Entity/CollectionElementLoader.cs trunk/nhibernate/src/NHibernate/Loader/Loader.cs trunk/nhibernate/src/NHibernate/Loader/OuterJoinLoader.cs Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Loader/QueryLoader.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Loader/QueryLoader.cs 2011-06-17 16:48:39 UTC (rev 5944) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Loader/QueryLoader.cs 2011-06-17 17:43:54 UTC (rev 5945) @@ -433,26 +433,14 @@ return result; } - public override ISqlCommand CreateSqlCommand(QueryParameters queryParameters, ISessionImplementor session) + protected override void ResetEffectiveExpectedType(IEnumerable<IParameterSpecification> parameterSpecs, QueryParameters queryParameters) { - // A distinct-copy of parameter specifications collected during query construction - var parameterSpecs = new HashSet<IParameterSpecification>(_queryTranslator.CollectedParameterSpecifications); - SqlString sqlString = SqlString.Copy(); - - // dynamic-filter parameters: during the HQL->SQL parsing, filters can be added as SQL_TOKEN/string and the SqlGenerator will not find it - sqlString = ExpandDynamicFilterParameters(sqlString, parameterSpecs, session); - AdjustQueryParametersForSubSelectFetching(sqlString, parameterSpecs, queryParameters); // NOTE: see TODO below - - sqlString = AddLimitsParametersIfNeeded(sqlString, parameterSpecs, queryParameters, session); - // TODO: for sub-select fetching we have to try to assign the QueryParameter.ProcessedSQL here (with limits) but only after use IParameterSpecification for any kind of queries and taking care about the work done by SubselectClauseExtractor - - // The PreprocessSQL method can modify the SqlString but should never add parameters (or we have to override it) - sqlString = PreprocessSQL(sqlString, queryParameters, session.Factory.Dialect); - - // After the last modification to the SqlString we can collect all parameters types. parameterSpecs.ResetEffectiveExpectedType(queryParameters); + } - return new SqlCommandImpl(sqlString, parameterSpecs, queryParameters, session.Factory); + protected override IEnumerable<IParameterSpecification> GetParameterSpecifications() + { + return _queryTranslator.CollectedParameterSpecifications; } } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Hql/Classic/QueryTranslator.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Classic/QueryTranslator.cs 2011-06-17 16:48:39 UTC (rev 5944) +++ trunk/nhibernate/src/NHibernate/Hql/Classic/QueryTranslator.cs 2011-06-17 17:43:54 UTC (rev 5945) @@ -301,26 +301,14 @@ get { return ((superQuery != null) ? superQuery.CollectedParameterSpecifications:Enumerable.Empty<IParameterSpecification>()).Concat(collectedParameters); } } - public override ISqlCommand CreateSqlCommand(QueryParameters queryParameters, ISessionImplementor session) + protected override void ResetEffectiveExpectedType(IEnumerable<IParameterSpecification> parameterSpecs, QueryParameters queryParameters) { - // A distinct-copy of parameter specifications collected during query construction - var parameterSpecs = new HashSet<IParameterSpecification>(CollectedParameterSpecifications); - SqlString sql = SqlString.Copy(); - - // dynamic-filter parameters: during the HQL->SQL parsing, filters can be added as SQL_TOKEN/string and the SqlGenerator will not find it - sql = ExpandDynamicFilterParameters(sql, parameterSpecs, session); - AdjustQueryParametersForSubSelectFetching(sql, parameterSpecs, queryParameters); // NOTE: see TODO below - - sql = AddLimitsParametersIfNeeded(sql, parameterSpecs, queryParameters, session); - // TODO: for sub-select fetching we have to try to assign the QueryParameter.ProcessedSQL here (with limits) but only after use IParameterSpecification for any kind of queries - - // The PreprocessSQL method can modify the SqlString but should never add parameters (or we have to override it) - sql = PreprocessSQL(sql, queryParameters, session.Factory.Dialect); - - // After the last modification to the SqlString we can collect all parameters types. parameterSpecs.ResetEffectiveExpectedType(queryParameters); + } - return new SqlCommandImpl(sql, parameterSpecs, queryParameters, session.Factory); + protected override IEnumerable<IParameterSpecification> GetParameterSpecifications() + { + return CollectedParameterSpecifications; } /// <summary> Modified: trunk/nhibernate/src/NHibernate/Loader/Collection/CollectionLoader.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Loader/Collection/CollectionLoader.cs 2011-06-17 16:48:39 UTC (rev 5944) +++ trunk/nhibernate/src/NHibernate/Loader/Collection/CollectionLoader.cs 2011-06-17 17:43:54 UTC (rev 5945) @@ -63,7 +63,7 @@ return specifications; } - protected override IEnumerable<IParameterSpecification> GetParameterSpecifications(QueryParameters queryParameters, ISessionFactoryImplementor sessionFactory) + protected override IEnumerable<IParameterSpecification> GetParameterSpecifications() { return parametersSpecifications ?? (parametersSpecifications = CreateParameterSpecificationsAndAssignBackTrack(SqlString.GetParameters()).ToArray()); } Modified: trunk/nhibernate/src/NHibernate/Loader/Collection/SubselectCollectionLoader.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Loader/Collection/SubselectCollectionLoader.cs 2011-06-17 16:48:39 UTC (rev 5944) +++ trunk/nhibernate/src/NHibernate/Loader/Collection/SubselectCollectionLoader.cs 2011-06-17 17:43:54 UTC (rev 5945) @@ -30,10 +30,9 @@ keys[i++] = entityKey.Identifier; } - namedParameters = queryParameters.NamedParameters; - // NH Different behavior: to deal with positionslParameter+NamedParameter+ParameterOfFilters parametersSpecifications = queryParameters.ProcessedSqlParameters.ToList(); + namedParameters = queryParameters.NamedParameters; types = queryParameters.PositionalParameterTypes; values = queryParameters.PositionalParameterValues; this.namedParameterLocMap = namedParameterLocMap; @@ -49,7 +48,7 @@ return namedParameterLocMap[name]; } - protected override IEnumerable<IParameterSpecification> GetParameterSpecifications(QueryParameters queryParameters, ISessionFactoryImplementor sessionFactory) + protected override IEnumerable<IParameterSpecification> GetParameterSpecifications() { return parametersSpecifications; } Modified: trunk/nhibernate/src/NHibernate/Loader/Collection/SubselectOneToManyLoader.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Loader/Collection/SubselectOneToManyLoader.cs 2011-06-17 16:48:39 UTC (rev 5944) +++ trunk/nhibernate/src/NHibernate/Loader/Collection/SubselectOneToManyLoader.cs 2011-06-17 17:43:54 UTC (rev 5945) @@ -33,9 +33,9 @@ keys[i++] = entityKey.Identifier; } - namedParameters = queryParameters.NamedParameters; // NH Different behavior: to deal with positionslParameter+NamedParameter+ParameterOfFilters parametersSpecifications = queryParameters.ProcessedSqlParameters.ToList(); + namedParameters = queryParameters.NamedParameters; types = queryParameters.PositionalParameterTypes; values = queryParameters.PositionalParameterValues; this.namedParameterLocMap = namedParameterLocMap; @@ -51,7 +51,7 @@ return namedParameterLocMap[name]; } - protected override IEnumerable<IParameterSpecification> GetParameterSpecifications(QueryParameters queryParameters, ISessionFactoryImplementor sessionFactory) + protected override IEnumerable<IParameterSpecification> GetParameterSpecifications() { return parametersSpecifications; } Modified: trunk/nhibernate/src/NHibernate/Loader/Criteria/CriteriaLoader.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Loader/Criteria/CriteriaLoader.cs 2011-06-17 16:48:39 UTC (rev 5944) +++ trunk/nhibernate/src/NHibernate/Loader/Criteria/CriteriaLoader.cs 2011-06-17 17:43:54 UTC (rev 5945) @@ -182,23 +182,9 @@ return customResultTransformer.TransformList(results); } - public override ISqlCommand CreateSqlCommand(QueryParameters queryParameters, ISessionImplementor session) + protected override IEnumerable<IParameterSpecification> GetParameterSpecifications() { - // A distinct-copy of parameter specifications collected during query construction - var parameterSpecs = new HashSet<IParameterSpecification>(translator.CollectedParameterSpecifications); - SqlString sqlString = SqlString.Copy(); - - // dynamic-filter parameters: during the Criteria parsing, filters can be added as string. - sqlString = ExpandDynamicFilterParameters(sqlString, parameterSpecs, session); - AdjustQueryParametersForSubSelectFetching(sqlString, parameterSpecs, queryParameters); // NOTE: see TODO below - - sqlString = AddLimitsParametersIfNeeded(sqlString, parameterSpecs, queryParameters, session); - // TODO: for sub-select fetching we have to try to assign the QueryParameter.ProcessedSQL here (with limits) but only after use IParameterSpecification for any kind of queries and taking care about the work done by SubselectClauseExtractor - - // The PreprocessSQL method can modify the SqlString but should never add parameters (or we have to override it) - sqlString = PreprocessSQL(sqlString, queryParameters, session.Factory.Dialect); - - return new SqlCommandImpl(sqlString, parameterSpecs, queryParameters, session.Factory); + return translator.CollectedParameterSpecifications; } public override int[] GetNamedParameterLocs(string name) Modified: trunk/nhibernate/src/NHibernate/Loader/Custom/CustomLoader.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Loader/Custom/CustomLoader.cs 2011-06-17 16:48:39 UTC (rev 5944) +++ trunk/nhibernate/src/NHibernate/Loader/Custom/CustomLoader.cs 2011-06-17 17:43:54 UTC (rev 5945) @@ -343,26 +343,14 @@ transformerAliases = aliases.ToArray(); } - public override ISqlCommand CreateSqlCommand(QueryParameters queryParameters, ISessionImplementor session) + protected override void ResetEffectiveExpectedType(IEnumerable<IParameterSpecification> parameterSpecs, QueryParameters queryParameters) { - // A distinct-copy of parameter specifications collected during query construction - var parameterSpecs = new HashSet<IParameterSpecification>(parametersSpecifications); - SqlString sqlString = SqlString.Copy(); - - // dynamic-filter parameters ? - //sqlString = ExpandDynamicFilterParameters(sqlString, parameterSpecs, session); - //AdjustQueryParametersForSubSelectFetching(sqlString, parameterSpecs, session, queryParameters); // NOTE: see TODO below - - sqlString = AddLimitsParametersIfNeeded(sqlString, parameterSpecs, queryParameters, session); - // TODO: for sub-select fetching we have to try to assign the QueryParameter.ProcessedSQL here (with limits) but only after use IParameterSpecification for any kind of queries and taking care about the work done by SubselectClauseExtractor - - // The PreprocessSQL method can modify the SqlString but should never add parameters (or we have to override it) - sqlString = PreprocessSQL(sqlString, queryParameters, session.Factory.Dialect); - - // After the last modification to the SqlString we can collect all parameters types. parameterSpecs.ResetEffectiveExpectedType(queryParameters); + } - return new SqlCommandImpl(sqlString, parameterSpecs, queryParameters, session.Factory); + protected override IEnumerable<IParameterSpecification> GetParameterSpecifications() + { + return parametersSpecifications; } public IType[] ResultTypes Modified: trunk/nhibernate/src/NHibernate/Loader/Entity/AbstractEntityLoader.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Loader/Entity/AbstractEntityLoader.cs 2011-06-17 16:48:39 UTC (rev 5944) +++ trunk/nhibernate/src/NHibernate/Loader/Entity/AbstractEntityLoader.cs 2011-06-17 17:43:54 UTC (rev 5945) @@ -92,7 +92,7 @@ return specifications; } - protected override IEnumerable<IParameterSpecification> GetParameterSpecifications(QueryParameters queryParameters, ISessionFactoryImplementor sessionFactory) + protected override IEnumerable<IParameterSpecification> GetParameterSpecifications() { return parametersSpecifications ?? (parametersSpecifications = CreateParameterSpecificationsAndAssignBackTrack(SqlString.GetParameters()).ToArray()); } Modified: trunk/nhibernate/src/NHibernate/Loader/Entity/CollectionElementLoader.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Loader/Entity/CollectionElementLoader.cs 2011-06-17 16:48:39 UTC (rev 5944) +++ trunk/nhibernate/src/NHibernate/Loader/Entity/CollectionElementLoader.cs 2011-06-17 17:43:54 UTC (rev 5945) @@ -59,7 +59,7 @@ return specifications; } - protected override IEnumerable<IParameterSpecification> GetParameterSpecifications(QueryParameters queryParameters, ISessionFactoryImplementor sessionFactory) + protected override IEnumerable<IParameterSpecification> GetParameterSpecifications() { return parametersSpecifications ?? (parametersSpecifications = CreateParameterSpecificationsAndAssignBackTrack(SqlString.GetParameters()).ToArray()); } Modified: trunk/nhibernate/src/NHibernate/Loader/Loader.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Loader/Loader.cs 2011-06-17 16:48:39 UTC (rev 5944) +++ trunk/nhibernate/src/NHibernate/Loader/Loader.cs 2011-06-17 17:43:54 UTC (rev 5945) @@ -1641,15 +1641,11 @@ public virtual ISqlCommand CreateSqlCommand(QueryParameters queryParameters, ISessionImplementor session) { - // The implementation of this method is itended to be used just for "internal" command (not for queries coming from users) - // Internally NH creates various commands, all using just positional-parameters, to then potentially apply dynamic-filters and pagination. - // In practice this method should be overriden by those loaders representing a user-query as CriteriaLoader, QueryLoader, classic QueryTraslator, CustomLoader (for custmon SQL queries). - // A distinct-copy of parameter specifications collected during query construction - var parameterSpecs = new HashSet<IParameterSpecification>(GetParameterSpecifications(queryParameters, session.Factory)); + var parameterSpecs = new HashSet<IParameterSpecification>(GetParameterSpecifications()); SqlString sqlString = SqlString.Copy(); - // dynamic-filter parameters: during the HQL->SQL parsing, filters can be added as SQL_TOKEN/string and the SqlGenerator will not find it + // dynamic-filter parameters: during the createion of the SqlString of allLoader implementation, filters can be added as SQL_TOKEN/string for this reason we have to re-parse the SQL. sqlString = ExpandDynamicFilterParameters(sqlString, parameterSpecs, session); AdjustQueryParametersForSubSelectFetching(sqlString, parameterSpecs, queryParameters); // NOTE: see TODO below @@ -1659,25 +1655,19 @@ // The PreprocessSQL method can modify the SqlString but should never add parameters (or we have to override it) sqlString = PreprocessSQL(sqlString, queryParameters, session.Factory.Dialect); + // After the last modification to the SqlString we can collect all parameters types (there are cases where we can't infer the type during the creation of the query) + ResetEffectiveExpectedType(parameterSpecs, queryParameters); + return new SqlCommandImpl(sqlString, parameterSpecs, queryParameters, session.Factory); } - protected virtual IEnumerable<IParameterSpecification> GetParameterSpecifications(QueryParameters queryParameters, ISessionFactoryImplementor sessionFactory) + protected virtual void ResetEffectiveExpectedType(IEnumerable<IParameterSpecification> parameterSpecs, QueryParameters queryParameters) { - // TODO FM: remove this implementation and put an abstract ParameterSpecifications in the Loader (each concrete implementation have to expose it) => NH1990, SubselectFetchFixture - var positionalSpecifications = queryParameters.PositionalParameterTypes.Select((t, i) => (IParameterSpecification)new PositionalParameterSpecification(1, 0, i) { ExpectedType = t }); - var namedSpecifications = queryParameters.NamedParameters != null ? queryParameters.NamedParameters.Select(np => (IParameterSpecification)new NamedParameterSpecification(1, 0, np.Key) { ExpectedType = np.Value.Type }): Enumerable.Empty<IParameterSpecification>(); - var specifications= positionalSpecifications.Concat(namedSpecifications).ToList(); - var parameters = SqlString.GetParameters().ToArray(); - var sqlParameterPos = 0; - var paramTrackers = specifications.SelectMany(specification => specification.GetIdsForBackTrack(sessionFactory)); - foreach (var paramTracker in paramTrackers) - { - parameters[sqlParameterPos++].BackTrack = paramTracker; - } - return specifications; + // Have to be overridden just by those loaders that can't infer the type during the parse process } + protected abstract IEnumerable<IParameterSpecification> GetParameterSpecifications(); + protected void AdjustQueryParametersForSubSelectFetching(SqlString sqlString, IEnumerable<IParameterSpecification> parameterSpecs, QueryParameters queryParameters) { queryParameters.ProcessedSql = sqlString; Modified: trunk/nhibernate/src/NHibernate/Loader/OuterJoinLoader.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Loader/OuterJoinLoader.cs 2011-06-17 16:48:39 UTC (rev 5944) +++ trunk/nhibernate/src/NHibernate/Loader/OuterJoinLoader.cs 2011-06-17 17:43:54 UTC (rev 5945) @@ -14,7 +14,7 @@ /// Generates an SQL select string containing all properties of those classes. /// Tablse are joined using an ANSI-style left outer join. /// </remarks> - public class OuterJoinLoader : BasicLoader + public abstract class OuterJoinLoader : BasicLoader { // Having these fields as protected prevents CLS compliance, so they are // private in NHibernate, and setters are created for the relevant @@ -32,7 +32,7 @@ private readonly IDictionary<string, IFilter> enabledFilters; - public OuterJoinLoader(ISessionFactoryImplementor factory, IDictionary<string, IFilter> enabledFilters) + protected OuterJoinLoader(ISessionFactoryImplementor factory, IDictionary<string, IFilter> enabledFilters) : base(factory) { this.enabledFilters = enabledFilters; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2011-06-17 16:48:45
|
Revision: 5944 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5944&view=rev Author: fabiomaulo Date: 2011-06-17 16:48:39 +0000 (Fri, 17 Jun 2011) Log Message: ----------- Collections loaders with parameter specifications Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Loader/Collection/CollectionLoader.cs trunk/nhibernate/src/NHibernate/Loader/Entity/AbstractEntityLoader.cs trunk/nhibernate/src/NHibernate/Loader/Entity/CollectionElementLoader.cs trunk/nhibernate/src/NHibernate/Loader/OuterJoinLoader.cs Modified: trunk/nhibernate/src/NHibernate/Loader/Collection/CollectionLoader.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Loader/Collection/CollectionLoader.cs 2011-06-17 13:48:05 UTC (rev 5943) +++ trunk/nhibernate/src/NHibernate/Loader/Collection/CollectionLoader.cs 2011-06-17 16:48:39 UTC (rev 5944) @@ -1,6 +1,9 @@ using System.Collections.Generic; +using System.Linq; using NHibernate.Engine; +using NHibernate.Param; using NHibernate.Persister.Collection; +using NHibernate.SqlCommand; using NHibernate.Type; namespace NHibernate.Loader.Collection @@ -13,6 +16,7 @@ public class CollectionLoader : OuterJoinLoader, ICollectionInitializer { private readonly IQueryableCollection collectionPersister; + private IParameterSpecification[] parametersSpecifications; public CollectionLoader(IQueryableCollection persister, ISessionFactoryImplementor factory, IDictionary<string, IFilter> enabledFilters) : base(factory, enabledFilters) @@ -39,5 +43,29 @@ { return GetType().FullName + '(' + collectionPersister.Role + ')'; } + + protected virtual IEnumerable<IParameterSpecification> CreateParameterSpecificationsAndAssignBackTrack(IEnumerable<Parameter> sqlPatameters) + { + // This implementation can manage even the case of batch-loading + var specifications = new List<IParameterSpecification>(); + int position = 0; + var parameters = sqlPatameters.ToArray(); + for (var sqlParameterPos = 0; sqlParameterPos < parameters.Length; ) + { + var specification = new PositionalParameterSpecification(1, 0, position++) { ExpectedType = KeyType }; + var paramTrackers = specification.GetIdsForBackTrack(Factory); + foreach (var paramTracker in paramTrackers) + { + parameters[sqlParameterPos++].BackTrack = paramTracker; + } + specifications.Add(specification); + } + return specifications; + } + + protected override IEnumerable<IParameterSpecification> GetParameterSpecifications(QueryParameters queryParameters, ISessionFactoryImplementor sessionFactory) + { + return parametersSpecifications ?? (parametersSpecifications = CreateParameterSpecificationsAndAssignBackTrack(SqlString.GetParameters()).ToArray()); + } } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Loader/Entity/AbstractEntityLoader.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Loader/Entity/AbstractEntityLoader.cs 2011-06-17 13:48:05 UTC (rev 5943) +++ trunk/nhibernate/src/NHibernate/Loader/Entity/AbstractEntityLoader.cs 2011-06-17 16:48:39 UTC (rev 5944) @@ -74,12 +74,6 @@ protected IType UniqueKeyType { get; private set; } - protected override void InitFromWalker(JoinWalker walker) - { - base.InitFromWalker(walker); - parametersSpecifications = CreateParameterSpecificationsAndAssignBackTrack(SqlString.GetParameters()).ToArray(); - } - private IEnumerable<IParameterSpecification> CreateParameterSpecificationsAndAssignBackTrack(IEnumerable<Parameter> sqlPatameters) { var specifications = new List<IParameterSpecification>(); @@ -100,7 +94,7 @@ protected override IEnumerable<IParameterSpecification> GetParameterSpecifications(QueryParameters queryParameters, ISessionFactoryImplementor sessionFactory) { - return parametersSpecifications; + return parametersSpecifications ?? (parametersSpecifications = CreateParameterSpecificationsAndAssignBackTrack(SqlString.GetParameters()).ToArray()); } } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Loader/Entity/CollectionElementLoader.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Loader/Entity/CollectionElementLoader.cs 2011-06-17 13:48:05 UTC (rev 5943) +++ trunk/nhibernate/src/NHibernate/Loader/Entity/CollectionElementLoader.cs 2011-06-17 16:48:39 UTC (rev 5944) @@ -1,10 +1,12 @@ using System.Collections; using System.Collections.Generic; using System.Data; - +using System.Linq; using NHibernate.Engine; +using NHibernate.Param; using NHibernate.Persister.Collection; using NHibernate.Persister.Entity; +using NHibernate.SqlCommand; using NHibernate.Transform; using NHibernate.Type; using NHibernate.Util; @@ -19,6 +21,7 @@ private readonly IType keyType; private readonly IType indexType; private readonly string entityName; + private IParameterSpecification[] parametersSpecifications; public CollectionElementLoader(IQueryableCollection collectionPersister, ISessionFactoryImplementor factory, IDictionary<string, IFilter> enabledFilters) : base(factory, enabledFilters) @@ -39,6 +42,28 @@ log.Debug("Static select for entity " + entityName + ": " + SqlString); } + private IEnumerable<IParameterSpecification> CreateParameterSpecificationsAndAssignBackTrack(IEnumerable<Parameter> sqlPatameters) + { + var specifications = new IParameterSpecification[] + { + new PositionalParameterSpecification(1, 0, 0) {ExpectedType = keyType}, + new PositionalParameterSpecification(1, 0, 1) {ExpectedType = indexType}, + }; + Parameter[] parameters = sqlPatameters.ToArray(); + int sqlParameterPos = 0; + IEnumerable<string> paramTrackers = specifications.SelectMany(specification => specification.GetIdsForBackTrack(Factory)); + foreach (string paramTracker in paramTrackers) + { + parameters[sqlParameterPos++].BackTrack = paramTracker; + } + return specifications; + } + + protected override IEnumerable<IParameterSpecification> GetParameterSpecifications(QueryParameters queryParameters, ISessionFactoryImplementor sessionFactory) + { + return parametersSpecifications ?? (parametersSpecifications = CreateParameterSpecificationsAndAssignBackTrack(SqlString.GetParameters()).ToArray()); + } + protected override bool IsSingleRowLoader { get { return true; } Modified: trunk/nhibernate/src/NHibernate/Loader/OuterJoinLoader.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Loader/OuterJoinLoader.cs 2011-06-17 13:48:05 UTC (rev 5943) +++ trunk/nhibernate/src/NHibernate/Loader/OuterJoinLoader.cs 2011-06-17 16:48:39 UTC (rev 5944) @@ -98,7 +98,7 @@ get { return collectionPersisters; } } - protected virtual void InitFromWalker(JoinWalker walker) + protected void InitFromWalker(JoinWalker walker) { persisters = walker.Persisters; collectionPersisters = walker.CollectionPersisters; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2011-06-17 13:48:11
|
Revision: 5943 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5943&view=rev Author: fabiomaulo Date: 2011-06-17 13:48:05 +0000 (Fri, 17 Jun 2011) Log Message: ----------- EntityLoader with parameter specifications Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Loader/Entity/AbstractEntityLoader.cs trunk/nhibernate/src/NHibernate/Loader/OuterJoinLoader.cs Modified: trunk/nhibernate/src/NHibernate/Loader/Entity/AbstractEntityLoader.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Loader/Entity/AbstractEntityLoader.cs 2011-06-17 12:08:27 UTC (rev 5942) +++ trunk/nhibernate/src/NHibernate/Loader/Entity/AbstractEntityLoader.cs 2011-06-17 13:48:05 UTC (rev 5943) @@ -1,9 +1,11 @@ using System.Collections; using System.Collections.Generic; using System.Data; - +using System.Linq; using NHibernate.Engine; +using NHibernate.Param; using NHibernate.Persister.Entity; +using NHibernate.SqlCommand; using NHibernate.Transform; using NHibernate.Type; @@ -16,13 +18,13 @@ { protected static readonly IInternalLogger log = LoggerProvider.LoggerFor(typeof (AbstractEntityLoader)); protected readonly IOuterJoinLoadable persister; - protected readonly IType uniqueKeyType; protected readonly string entityName; + private IParameterSpecification[] parametersSpecifications; - public AbstractEntityLoader(IOuterJoinLoadable persister, IType uniqueKeyType, ISessionFactoryImplementor factory, + protected AbstractEntityLoader(IOuterJoinLoadable persister, IType uniqueKeyType, ISessionFactoryImplementor factory, IDictionary<string, IFilter> enabledFilters) : base(factory, enabledFilters) { - this.uniqueKeyType = uniqueKeyType; + UniqueKeyType = uniqueKeyType; entityName = persister.EntityName; this.persister = persister; } @@ -39,7 +41,7 @@ protected virtual object Load(ISessionImplementor session, object id, object optionalObject, object optionalId) { - IList list = LoadEntity(session, id, uniqueKeyType, optionalObject, entityName, optionalId, persister); + IList list = LoadEntity(session, id, UniqueKeyType, optionalObject, entityName, optionalId, persister); if (list.Count == 1) { @@ -69,5 +71,36 @@ { return row[row.Length - 1]; } + + protected IType UniqueKeyType { get; private set; } + + protected override void InitFromWalker(JoinWalker walker) + { + base.InitFromWalker(walker); + parametersSpecifications = CreateParameterSpecificationsAndAssignBackTrack(SqlString.GetParameters()).ToArray(); + } + + private IEnumerable<IParameterSpecification> CreateParameterSpecificationsAndAssignBackTrack(IEnumerable<Parameter> sqlPatameters) + { + var specifications = new List<IParameterSpecification>(); + int position = 0; + var parameters = sqlPatameters.ToArray(); + for (var sqlParameterPos = 0; sqlParameterPos < parameters.Length;) + { + var specification = new PositionalParameterSpecification(1, 0, position++) {ExpectedType = UniqueKeyType}; + var paramTrackers = specification.GetIdsForBackTrack(Factory); + foreach (var paramTracker in paramTrackers) + { + parameters[sqlParameterPos++].BackTrack = paramTracker; + } + specifications.Add(specification); + } + return specifications; + } + + protected override IEnumerable<IParameterSpecification> GetParameterSpecifications(QueryParameters queryParameters, ISessionFactoryImplementor sessionFactory) + { + return parametersSpecifications; + } } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Loader/OuterJoinLoader.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Loader/OuterJoinLoader.cs 2011-06-17 12:08:27 UTC (rev 5942) +++ trunk/nhibernate/src/NHibernate/Loader/OuterJoinLoader.cs 2011-06-17 13:48:05 UTC (rev 5943) @@ -98,7 +98,7 @@ get { return collectionPersisters; } } - protected void InitFromWalker(JoinWalker walker) + protected virtual void InitFromWalker(JoinWalker walker) { persisters = walker.Persisters; collectionPersisters = walker.CollectionPersisters; @@ -108,7 +108,7 @@ collectionSuffixes = walker.CollectionSuffixes; owners = walker.Owners; collectionOwners = walker.CollectionOwners; - sql = walker.SqlString; + sql = walker.SqlString.Compact(); aliases = walker.Aliases; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2011-06-17 12:08:33
|
Revision: 5942 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5942&view=rev Author: fabiomaulo Date: 2011-06-17 12:08:27 +0000 (Fri, 17 Jun 2011) Log Message: ----------- Removed TODO Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Loader/Loader.cs Modified: trunk/nhibernate/src/NHibernate/Loader/Loader.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Loader/Loader.cs 2011-06-17 12:05:56 UTC (rev 5941) +++ trunk/nhibernate/src/NHibernate/Loader/Loader.cs 2011-06-17 12:08:27 UTC (rev 5942) @@ -1680,7 +1680,6 @@ protected void AdjustQueryParametersForSubSelectFetching(SqlString sqlString, IEnumerable<IParameterSpecification> parameterSpecs, QueryParameters queryParameters) { - // TODO: Remove this when all parameters are managed using IParameterSpecification (QueryParameters does not need to have decomposed values for filters) queryParameters.ProcessedSql = sqlString; queryParameters.ProcessedSqlParameters = parameterSpecs.ToList(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2011-06-17 12:06:02
|
Revision: 5941 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5941&view=rev Author: fabiomaulo Date: 2011-06-17 12:05:56 +0000 (Fri, 17 Jun 2011) Log Message: ----------- Fix NH-2770 Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Cfg/Loquacious/DbIntegrationConfiguration.cs trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IDbIntegrationConfiguration.cs trunk/nhibernate/src/NHibernate.Test/GhostProperty/GhostPropertyFixture.cs Modified: trunk/nhibernate/src/NHibernate/Cfg/Loquacious/DbIntegrationConfiguration.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/Loquacious/DbIntegrationConfiguration.cs 2011-06-17 12:03:42 UTC (rev 5940) +++ trunk/nhibernate/src/NHibernate/Cfg/Loquacious/DbIntegrationConfiguration.cs 2011-06-17 12:05:56 UTC (rev 5941) @@ -304,7 +304,7 @@ set { configuration.SetProperty(Environment.ShowSql, value.ToString().ToLowerInvariant()); } } - public bool LogFormatedSql + public bool LogFormattedSql { set { configuration.SetProperty(Environment.FormatSql, value.ToString().ToLowerInvariant()); } } Modified: trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IDbIntegrationConfiguration.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IDbIntegrationConfiguration.cs 2011-06-17 12:03:42 UTC (rev 5940) +++ trunk/nhibernate/src/NHibernate/Cfg/Loquacious/IDbIntegrationConfiguration.cs 2011-06-17 12:05:56 UTC (rev 5941) @@ -36,7 +36,7 @@ void Dialect<TDialect>() where TDialect : Dialect.Dialect; Hbm2DDLKeyWords KeywordsAutoImport { set; } bool LogSqlInConsole { set; } - bool LogFormatedSql { set; } + bool LogFormattedSql { set; } void ConnectionProvider<TProvider>() where TProvider : IConnectionProvider; void Driver<TDriver>() where TDriver : IDriver; Modified: trunk/nhibernate/src/NHibernate.Test/GhostProperty/GhostPropertyFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/GhostProperty/GhostPropertyFixture.cs 2011-06-17 12:03:42 UTC (rev 5940) +++ trunk/nhibernate/src/NHibernate.Test/GhostProperty/GhostPropertyFixture.cs 2011-06-17 12:05:56 UTC (rev 5941) @@ -24,7 +24,7 @@ protected override void Configure(Cfg.Configuration configuration) { - configuration.DataBaseIntegration(x=> x.LogFormatedSql = false); + configuration.DataBaseIntegration(x=> x.LogFormattedSql = false); } protected override void OnSetUp() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2011-06-17 12:03:48
|
Revision: 5940 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5940&view=rev Author: fabiomaulo Date: 2011-06-17 12:03:42 +0000 (Fri, 17 Jun 2011) Log Message: ----------- Removed no more needed code Modified Paths: -------------- trunk/nhibernate/releasenotes.txt trunk/nhibernate/src/NHibernate/Dialect/DB2Dialect.cs trunk/nhibernate/src/NHibernate/Dialect/Dialect.cs trunk/nhibernate/src/NHibernate/Dialect/InformixDialect.cs trunk/nhibernate/src/NHibernate/Dialect/MsSql2005Dialect.cs trunk/nhibernate/src/NHibernate/Dialect/Oracle8iDialect.cs trunk/nhibernate/src/NHibernate/Dialect/PostgreSQLDialect.cs trunk/nhibernate/src/NHibernate/Dialect/SybaseSQLAnywhere10Dialect.cs trunk/nhibernate/src/NHibernate/Loader/Loader.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2467/NH2467Test.cs trunk/nhibernate/src/NHibernate.Test/Pagination/CustomMsSqlDialect.cs Modified: trunk/nhibernate/releasenotes.txt =================================================================== --- trunk/nhibernate/releasenotes.txt 2011-06-16 17:32:25 UTC (rev 5939) +++ trunk/nhibernate/releasenotes.txt 2011-06-17 12:03:42 UTC (rev 5940) @@ -12,6 +12,7 @@ * [NH-2605] Refactorize MultiQuery/MultiCriteria implementation to delegate responsibility to IDrive (IDrive changed). * For users who don't look at Log-ERROR, to prevent wrong behavior when lazy-properties are used the DynamicProxyValidator validates the accessability of properties setters. * For those implementing IDrive without inherit from DriveBase: IDrive.AdjustCommand + * Dialect base: removed some no more needed properties Build 3.2.0.Beta1 (rev5839) ============================= Modified: trunk/nhibernate/src/NHibernate/Dialect/DB2Dialect.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Dialect/DB2Dialect.cs 2011-06-16 17:32:25 UTC (rev 5939) +++ trunk/nhibernate/src/NHibernate/Dialect/DB2Dialect.cs 2011-06-17 12:03:42 UTC (rev 5940) @@ -194,12 +194,6 @@ } /// <summary></summary> - public override bool BindLimitParametersInReverseOrder - { - get { return false; } - } - - /// <summary></summary> public override bool UseMaxForLimit { get { return true; } Modified: trunk/nhibernate/src/NHibernate/Dialect/Dialect.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Dialect/Dialect.cs 2011-06-16 17:32:25 UTC (rev 5939) +++ trunk/nhibernate/src/NHibernate/Dialect/Dialect.cs 2011-06-17 12:03:42 UTC (rev 5940) @@ -1639,27 +1639,6 @@ get { return SupportsLimit; } } - /// <summary> - /// Does the <c>LIMIT</c> clause specify arguments in the "reverse" order - /// limit, offset instead of offset, limit? - /// </summary> - /// <value>False, unless overridden.</value> - /// <remarks>Inheritors should return true if the correct order is limit, offset</remarks> - public virtual bool BindLimitParametersInReverseOrder - { - get { return false; } - } - - /// <summary> - /// Does the <c>LIMIT</c> clause come at the start of the - /// <c>SELECT</c> statement rather than at the end? - /// </summary> - /// <value>false, unless overridden</value> - public virtual bool BindLimitParametersFirst - { - get { return false; } - } - /// <summary> /// Does the <tt>LIMIT</tt> clause take a "maximum" row number instead /// of a total number of returned rows? Modified: trunk/nhibernate/src/NHibernate/Dialect/InformixDialect.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Dialect/InformixDialect.cs 2011-06-16 17:32:25 UTC (rev 5939) +++ trunk/nhibernate/src/NHibernate/Dialect/InformixDialect.cs 2011-06-17 12:03:42 UTC (rev 5940) @@ -366,16 +366,6 @@ get { return false; } } - /// <summary> - /// Does the <c>LIMIT</c> clause come at the start of the - /// <c>SELECT</c> statement rather than at the end? - /// </summary> - /// <value>false, unless overridden</value> - public override bool BindLimitParametersFirst - { - get { return true; } - } - public override SqlString GetLimitString(SqlString queryString, SqlString offset, SqlString limit) { /* Modified: trunk/nhibernate/src/NHibernate/Dialect/MsSql2005Dialect.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Dialect/MsSql2005Dialect.cs 2011-06-16 17:32:25 UTC (rev 5939) +++ trunk/nhibernate/src/NHibernate/Dialect/MsSql2005Dialect.cs 2011-06-17 12:03:42 UTC (rev 5940) @@ -205,21 +205,11 @@ get { return true; } } - public override bool BindLimitParametersInReverseOrder - { - get { return true; } - } - public override bool SupportsVariableLimit { get { return true; } } - public override bool BindLimitParametersFirst - { - get { return true; } - } - protected override string GetSelectExistingObject(string name, Table table) { string schema = table.GetQuotedSchemaName(this); Modified: trunk/nhibernate/src/NHibernate/Dialect/Oracle8iDialect.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Dialect/Oracle8iDialect.cs 2011-06-16 17:32:25 UTC (rev 5939) +++ trunk/nhibernate/src/NHibernate/Dialect/Oracle8iDialect.cs 2011-06-17 12:03:42 UTC (rev 5940) @@ -394,11 +394,6 @@ return ForUpdateString + " of " + aliases + " nowait"; } - public override bool BindLimitParametersInReverseOrder - { - get { return true; } - } - public override bool UseMaxForLimit { get { return true; } Modified: trunk/nhibernate/src/NHibernate/Dialect/PostgreSQLDialect.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Dialect/PostgreSQLDialect.cs 2011-06-16 17:32:25 UTC (rev 5939) +++ trunk/nhibernate/src/NHibernate/Dialect/PostgreSQLDialect.cs 2011-06-17 12:03:42 UTC (rev 5940) @@ -128,11 +128,6 @@ get { return true; } } - public override bool BindLimitParametersInReverseOrder - { - get { return true; } - } - public override SqlString GetLimitString(SqlString queryString, SqlString offset, SqlString limit) { SqlStringBuilder pagingBuilder = new SqlStringBuilder(); Modified: trunk/nhibernate/src/NHibernate/Dialect/SybaseSQLAnywhere10Dialect.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Dialect/SybaseSQLAnywhere10Dialect.cs 2011-06-16 17:32:25 UTC (rev 5939) +++ trunk/nhibernate/src/NHibernate/Dialect/SybaseSQLAnywhere10Dialect.cs 2011-06-17 12:03:42 UTC (rev 5940) @@ -415,23 +415,6 @@ get { return true; } } - /// <summary> - /// SQL Anywhere syntax is SELECT TOP n START AT m - /// </summary> - public override bool BindLimitParametersInReverseOrder - { - get { return true; } - } - - /// <summary> - /// SQL Anywhere 11 uses SELECT TOP n START AT m [ select list items ] - /// for LIMIT/OFFSET support. - /// </summary> - public override bool BindLimitParametersFirst - { - get { return true; } - } - private static int GetAfterSelectInsertPoint(SqlString sql) { // Assume no common table expressions with the statement. Modified: trunk/nhibernate/src/NHibernate/Loader/Loader.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Loader/Loader.cs 2011-06-16 17:32:25 UTC (rev 5939) +++ trunk/nhibernate/src/NHibernate/Loader/Loader.cs 2011-06-17 12:03:42 UTC (rev 5940) @@ -1189,42 +1189,7 @@ return dialect.GetLimitValue(firstRow, rowCount); } - private int GetFirstLimitParameterCount(Dialect.Dialect dialect, bool useLimit, bool hasFirstRow, bool useOffset) - { - if (!useLimit) return 0; - if (!dialect.SupportsVariableLimit) return 0; - if (!dialect.BindLimitParametersFirst) return 0; - return (hasFirstRow && useOffset) ? 2 : 1; - } - /// <summary> - /// Bind parameters needed by the dialect-specific LIMIT clause - /// </summary> - /// <returns>The number of parameters bound</returns> - internal int BindLimitParameters(IDbCommand st, int index, RowSelection selection, ISessionImplementor session) - { - Dialect.Dialect dialect = session.Factory.Dialect; - if (!dialect.SupportsVariableLimit) - { - return 0; - } - - int firstRow = GetFirstRow(selection); - int lastRow = GetMaxOrLimit(dialect, selection); - - bool hasFirstRow = firstRow > 0 && dialect.SupportsLimitOffset; - bool reverse = dialect.BindLimitParametersInReverseOrder; - - if (hasFirstRow) - { - ((IDataParameter) st.Parameters[index + (reverse ? 1 : 0)]).Value = firstRow; - } - ((IDataParameter) st.Parameters[index + ((reverse || !hasFirstRow) ? 0 : 1)]).Value = lastRow; - - return hasFirstRow ? 2 : 1; - } - - /// <summary> /// Limits the number of rows returned by the Sql query if necessary. /// </summary> /// <param name="st">The IDbCommand to limit.</param> Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2467/NH2467Test.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2467/NH2467Test.cs 2011-06-16 17:32:25 UTC (rev 5939) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2467/NH2467Test.cs 2011-06-17 12:03:42 UTC (rev 5940) @@ -20,7 +20,7 @@ protected override bool AppliesTo(Dialect.Dialect dialect) { - return dialect.SupportsLimit && !dialect.BindLimitParametersFirst; + return dialect.SupportsLimit; } protected override void OnTearDown() Modified: trunk/nhibernate/src/NHibernate.Test/Pagination/CustomMsSqlDialect.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Pagination/CustomMsSqlDialect.cs 2011-06-16 17:32:25 UTC (rev 5939) +++ trunk/nhibernate/src/NHibernate.Test/Pagination/CustomMsSqlDialect.cs 2011-06-17 12:03:42 UTC (rev 5940) @@ -11,7 +11,6 @@ public bool ForcedBindLimitParameterFirst; public bool ForcedSupportsVariableLimit; - public override bool BindLimitParametersFirst { get { return ForcedBindLimitParameterFirst; } } public override bool SupportsVariableLimit { get { return ForcedSupportsVariableLimit; } } } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2011-06-16 17:32:31
|
Revision: 5939 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5939&view=rev Author: fabiomaulo Date: 2011-06-16 17:32:25 +0000 (Thu, 16 Jun 2011) Log Message: ----------- Minor reformatting/refactoring (now it does not scare) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Engine/QueryParameters.cs Modified: trunk/nhibernate/src/NHibernate/Engine/QueryParameters.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Engine/QueryParameters.cs 2011-06-16 17:20:18 UTC (rev 5938) +++ trunk/nhibernate/src/NHibernate/Engine/QueryParameters.cs 2011-06-16 17:32:25 UTC (rev 5939) @@ -17,35 +17,18 @@ [Serializable] public sealed class QueryParameters { - public delegate int[] GetNamedParameterLocations(string parameterName); - private static readonly IInternalLogger log = LoggerProvider.LoggerFor(typeof (QueryParameters)); - private IType[] _positionalParameterTypes; - private object[] _positionalParameterValues; - private IDictionary<string, TypedValue> _namedParameters; - private IDictionary<string, LockMode> _lockModes; - private RowSelection _rowSelection; - private bool _cacheable; - private string _cacheRegion; - private object[] _collectionKeys; - private object _optionalObject; - private string _optionalEntityName; - private object _optionalId; - private bool _isReadOnlyInitialized; - private string _comment; - private bool _readOnly; - private SqlString processedSQL; - private readonly IResultTransformer _resultTransformer; - + private bool readOnly; + public QueryParameters() : this(ArrayHelper.EmptyTypeArray, ArrayHelper.EmptyObjectArray) {} public QueryParameters(IType[] positionalParameterTypes, object[] postionalParameterValues, object optionalObject, string optionalEntityName, object optionalObjectId) : this(positionalParameterTypes, postionalParameterValues) { - _optionalObject = optionalObject; - _optionalId = optionalObjectId; - _optionalEntityName = optionalEntityName; + OptionalObject = optionalObject; + OptionalId = optionalObjectId; + OptionalEntityName = optionalEntityName; } public QueryParameters(IType[] positionalParameterTypes, object[] postionalParameterValues) @@ -57,224 +40,180 @@ public QueryParameters(IType[] positionalParameterTypes, object[] postionalParameterValues, IDictionary<string, TypedValue> namedParameters, object[] collectionKeys) : this(positionalParameterTypes, postionalParameterValues, namedParameters, null, null, false, false, false, null, null, collectionKeys, null) {} - public QueryParameters(IType[] positionalParameterTypes, object[] positionalParameterValues, IDictionary<string, LockMode> lockModes, RowSelection rowSelection, bool isReadOnlyInitialized, bool readOnly, bool cacheable, string cacheRegion, string comment, bool isLookupByNaturalKey, IResultTransformer transformer) + public QueryParameters(IType[] positionalParameterTypes, object[] positionalParameterValues, IDictionary<string, LockMode> lockModes, RowSelection rowSelection, + bool isReadOnlyInitialized, bool readOnly, bool cacheable, string cacheRegion, string comment, bool isLookupByNaturalKey, IResultTransformer transformer) : this(positionalParameterTypes, positionalParameterValues, null, lockModes, rowSelection, isReadOnlyInitialized, readOnly, cacheable, cacheRegion, comment, null, transformer) { NaturalKeyLookup = isLookupByNaturalKey; } - public QueryParameters(IDictionary<string, TypedValue> namedParameters, IDictionary<string, LockMode> lockModes, RowSelection rowSelection, bool isReadOnlyInitialized, bool readOnly, bool cacheable, string cacheRegion, string comment, bool isLookupByNaturalKey, IResultTransformer transformer) - : this(ArrayHelper.EmptyTypeArray, ArrayHelper.EmptyObjectArray, namedParameters, lockModes, rowSelection, isReadOnlyInitialized, readOnly, cacheable, cacheRegion, comment, null, transformer) + public QueryParameters(IDictionary<string, TypedValue> namedParameters, IDictionary<string, LockMode> lockModes, RowSelection rowSelection, bool isReadOnlyInitialized, + bool readOnly, bool cacheable, string cacheRegion, string comment, bool isLookupByNaturalKey, IResultTransformer transformer) + : this( + ArrayHelper.EmptyTypeArray, ArrayHelper.EmptyObjectArray, namedParameters, lockModes, rowSelection, isReadOnlyInitialized, readOnly, cacheable, cacheRegion, comment, null, + transformer) { // used by CriteriaTranslator NaturalKeyLookup = isLookupByNaturalKey; } - public QueryParameters(IType[] positionalParameterTypes, object[] positionalParameterValues, IDictionary<string, TypedValue> namedParameters, IDictionary<string, LockMode> lockModes, RowSelection rowSelection, bool isReadOnlyInitialized, bool readOnly, bool cacheable, string cacheRegion, string comment, object[] collectionKeys, IResultTransformer transformer) + public QueryParameters(IType[] positionalParameterTypes, object[] positionalParameterValues, IDictionary<string, TypedValue> namedParameters, + IDictionary<string, LockMode> lockModes, RowSelection rowSelection, bool isReadOnlyInitialized, bool readOnly, bool cacheable, string cacheRegion, + string comment, object[] collectionKeys, IResultTransformer transformer) { - _positionalParameterTypes = positionalParameterTypes ?? new IType[0]; - _positionalParameterValues = positionalParameterValues ?? new IType[0]; - _namedParameters = namedParameters ?? new Dictionary<string, TypedValue>(1); - _lockModes = lockModes; - _rowSelection = rowSelection; - _cacheable = cacheable; - _cacheRegion = cacheRegion; - _comment = comment; - _collectionKeys = collectionKeys; - _isReadOnlyInitialized = isReadOnlyInitialized; - _readOnly = readOnly; - _resultTransformer = transformer; + PositionalParameterTypes = positionalParameterTypes ?? new IType[0]; + PositionalParameterValues = positionalParameterValues ?? new IType[0]; + NamedParameters = namedParameters ?? new Dictionary<string, TypedValue>(1); + LockModes = lockModes; + RowSelection = rowSelection; + Cacheable = cacheable; + CacheRegion = cacheRegion; + Comment = comment; + CollectionKeys = collectionKeys; + IsReadOnlyInitialized = isReadOnlyInitialized; + this.readOnly = readOnly; + ResultTransformer = transformer; } - public QueryParameters(IType[] positionalParameterTypes, object[] positionalParameterValues, IDictionary<string, TypedValue> namedParameters, IDictionary<string, LockMode> lockModes, RowSelection rowSelection, bool isReadOnlyInitialized, bool readOnly, bool cacheable, string cacheRegion, string comment, object[] collectionKeys, object optionalObject, string optionalEntityName, object optionalId, IResultTransformer transformer) - : this(positionalParameterTypes, positionalParameterValues, namedParameters, lockModes, rowSelection, isReadOnlyInitialized, readOnly, cacheable, cacheRegion, comment, collectionKeys, transformer) + public QueryParameters(IType[] positionalParameterTypes, object[] positionalParameterValues, IDictionary<string, TypedValue> namedParameters, + IDictionary<string, LockMode> lockModes, RowSelection rowSelection, bool isReadOnlyInitialized, bool readOnly, bool cacheable, string cacheRegion, + string comment, object[] collectionKeys, object optionalObject, string optionalEntityName, object optionalId, IResultTransformer transformer) + : this( + positionalParameterTypes, positionalParameterValues, namedParameters, lockModes, rowSelection, isReadOnlyInitialized, readOnly, cacheable, cacheRegion, comment, collectionKeys, + transformer) { - _optionalEntityName = optionalEntityName; - _optionalId = optionalId; - _optionalObject = optionalObject; + OptionalEntityName = optionalEntityName; + OptionalId = optionalId; + OptionalObject = optionalObject; } public bool HasRowSelection { - get { return _rowSelection != null; } + get { return RowSelection != null; } } - public IDictionary<string, TypedValue> NamedParameters - { - get { return _namedParameters; } - internal set { _namedParameters = value; } - } + public IDictionary<string, TypedValue> NamedParameters { get; internal set; } /// <summary> /// Gets or sets an array of <see cref="IType"/> objects that is stored at the index /// of the Parameter. /// </summary> - public IType[] PositionalParameterTypes - { - get { return _positionalParameterTypes; } - set { _positionalParameterTypes = value; } - } + public IType[] PositionalParameterTypes { get; set; } /// <summary> /// Gets or sets an array of <see cref="object"/> objects that is stored at the index /// of the Parameter. /// </summary> - public object[] PositionalParameterValues - { - get { return _positionalParameterValues; } - set { _positionalParameterValues = value; } - } + public object[] PositionalParameterValues { get; set; } /// <summary> /// Gets or sets the <see cref="RowSelection"/> for the Query. /// </summary> - public RowSelection RowSelection - { - get { return _rowSelection; } - set { _rowSelection = value; } - } + public RowSelection RowSelection { get; set; } /// <summary> /// Gets or sets an <see cref="IDictionary"/> that contains the alias name of the /// object from hql as the key and the <see cref="LockMode"/> as the value. /// </summary> /// <value>An <see cref="IDictionary"/> of lock modes.</value> - public IDictionary<string, LockMode> LockModes - { - get { return _lockModes; } - set { _lockModes = value; } - } + public IDictionary<string, LockMode> LockModes { get; set; } - public bool IsReadOnlyInitialized - { - get { return _isReadOnlyInitialized; } - } + public bool IsReadOnlyInitialized { get; private set; } - public void LogParameters(ISessionFactoryImplementor factory) - { - var print = new Printer(factory); - if (_positionalParameterValues.Length != 0) - { - log.Debug("parameters: " + print.ToString(_positionalParameterTypes, _positionalParameterValues)); - } + public bool Cacheable { get; set; } - if (_namedParameters != null) - { - log.Debug("named parameters: " + print.ToString(_namedParameters)); - } - } + public string CacheRegion { get; set; } - public bool Cacheable - { - get { return _cacheable; } - set { _cacheable = value; } - } + public string Comment { get; set; } - public string CacheRegion - { - get { return _cacheRegion; } - set { _cacheRegion = value; } - } - - public string Comment - { - get { return _comment; } - set { _comment = value; } - } - - /// <summary> - /// Ensure the Types and Values are the same length. - /// </summary> - /// <exception cref="QueryException"> - /// If the Lengths of <see cref="PositionalParameterTypes"/> and - /// <see cref="PositionalParameterValues"/> are not equal. - /// </exception> - public void ValidateParameters() - { - int typesLength = PositionalParameterTypes.Length; - int valuesLength = PositionalParameterValues.Length; - - if (typesLength != valuesLength) - { - throw new QueryException("Number of positional parameter types (" + typesLength - + ") does not match number of positional parameter values (" + valuesLength + ")"); - } - } - public bool ForceCacheRefresh { get; set; } - public string OptionalEntityName - { - get { return _optionalEntityName; } - set { _optionalEntityName = value; } - } + public string OptionalEntityName { get; set; } - public object OptionalId - { - get { return _optionalId; } - set { _optionalId = value; } - } + public object OptionalId { get; set; } - public object OptionalObject - { - get { return _optionalObject; } - set { _optionalObject = value; } - } + public object OptionalObject { get; set; } - public object[] CollectionKeys - { - get { return _collectionKeys; } - set { _collectionKeys = value; } - } + public object[] CollectionKeys { get; set; } public bool Callable { get; set; } - + public bool ReadOnly { get { - if (!_isReadOnlyInitialized) + if (!IsReadOnlyInitialized) + { throw new InvalidOperationException("cannot call ReadOnly when IsReadOnlyInitialized returns false"); + } - return _readOnly; + return readOnly; } set { - _readOnly = value; - _isReadOnlyInitialized = true; + readOnly = value; + IsReadOnlyInitialized = true; } } - public SqlString ProcessedSql - { - get { return processedSQL; } - internal set { processedSQL = value; } - } + public SqlString ProcessedSql { get; internal set; } public IEnumerable<IParameterSpecification> ProcessedSqlParameters { get; internal set; } public bool NaturalKeyLookup { get; set; } - public IResultTransformer ResultTransformer + public IResultTransformer ResultTransformer { get; private set; } + + public bool HasAutoDiscoverScalarTypes { get; set; } + + public void LogParameters(ISessionFactoryImplementor factory) { - get { return _resultTransformer; } + var print = new Printer(factory); + if (PositionalParameterValues.Length != 0) + { + log.Debug("parameters: " + print.ToString(PositionalParameterTypes, PositionalParameterValues)); + } + + if (NamedParameters != null) + { + log.Debug("named parameters: " + print.ToString(NamedParameters)); + } } - public bool HasAutoDiscoverScalarTypes { get; set; } + /// <summary> + /// Ensure the Types and Values are the same length. + /// </summary> + /// <exception cref="QueryException"> + /// If the Lengths of <see cref="PositionalParameterTypes"/> and + /// <see cref="PositionalParameterValues"/> are not equal. + /// </exception> + public void ValidateParameters() + { + int typesLength = PositionalParameterTypes == null ? 0 : PositionalParameterTypes.Length; + int valuesLength = PositionalParameterValues == null ? 0 : PositionalParameterValues.Length; + if (typesLength != valuesLength) + { + throw new QueryException("Number of positional parameter types (" + typesLength + + ") does not match number of positional parameter values (" + valuesLength + ")"); + } + } + public QueryParameters CreateCopyUsing(RowSelection selection) { - var copy = new QueryParameters(_positionalParameterTypes, _positionalParameterValues, _namedParameters, _lockModes, - selection, _isReadOnlyInitialized, _readOnly, _cacheable, _cacheRegion, _comment, _collectionKeys, - _optionalObject, _optionalEntityName, _optionalId, _resultTransformer); - copy.processedSQL = processedSQL; - copy.ProcessedSqlParameters = ProcessedSqlParameters.ToList(); + var copy = new QueryParameters(PositionalParameterTypes, PositionalParameterValues, NamedParameters, LockModes, + selection, IsReadOnlyInitialized, readOnly, Cacheable, CacheRegion, Comment, CollectionKeys, + OptionalObject, OptionalEntityName, OptionalId, ResultTransformer) + { + ProcessedSql = ProcessedSql, + ProcessedSqlParameters = ProcessedSqlParameters.ToList() + }; return copy; } - + public bool IsReadOnly(ISessionImplementor session) { - return _isReadOnlyInitialized ? this.ReadOnly : session.PersistenceContext.DefaultReadOnly; + return IsReadOnlyInitialized ? ReadOnly : session.PersistenceContext.DefaultReadOnly; } } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2011-06-16 17:20:24
|
Revision: 5938 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5938&view=rev Author: fabiomaulo Date: 2011-06-16 17:20:18 +0000 (Thu, 16 Jun 2011) Log Message: ----------- Minor refactoring Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Engine/QueryParameters.cs Modified: trunk/nhibernate/src/NHibernate/Engine/QueryParameters.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Engine/QueryParameters.cs 2011-06-16 16:59:59 UTC (rev 5937) +++ trunk/nhibernate/src/NHibernate/Engine/QueryParameters.cs 2011-06-16 17:20:18 UTC (rev 5938) @@ -72,9 +72,9 @@ public QueryParameters(IType[] positionalParameterTypes, object[] positionalParameterValues, IDictionary<string, TypedValue> namedParameters, IDictionary<string, LockMode> lockModes, RowSelection rowSelection, bool isReadOnlyInitialized, bool readOnly, bool cacheable, string cacheRegion, string comment, object[] collectionKeys, IResultTransformer transformer) { - _positionalParameterTypes = positionalParameterTypes; - _positionalParameterValues = positionalParameterValues; - _namedParameters = namedParameters; + _positionalParameterTypes = positionalParameterTypes ?? new IType[0]; + _positionalParameterValues = positionalParameterValues ?? new IType[0]; + _namedParameters = namedParameters ?? new Dictionary<string, TypedValue>(1); _lockModes = lockModes; _rowSelection = rowSelection; _cacheable = cacheable; @@ -102,7 +102,7 @@ public IDictionary<string, TypedValue> NamedParameters { get { return _namedParameters; } - set { _namedParameters = value; } + internal set { _namedParameters = value; } } /// <summary> @@ -150,15 +150,6 @@ get { return _isReadOnlyInitialized; } } - private int SafeLength(Array array) - { - if (array == null) - { - return 0; - } - return array.Length; - } - public void LogParameters(ISessionFactoryImplementor factory) { var print = new Printer(factory); @@ -200,8 +191,8 @@ /// </exception> public void ValidateParameters() { - int typesLength = SafeLength(PositionalParameterTypes); - int valuesLength = SafeLength(PositionalParameterValues); + int typesLength = PositionalParameterTypes.Length; + int valuesLength = PositionalParameterValues.Length; if (typesLength != valuesLength) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2011-06-16 17:00:06
|
Revision: 5937 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5937&view=rev Author: fabiomaulo Date: 2011-06-16 16:59:59 +0000 (Thu, 16 Jun 2011) Log Message: ----------- Removed no more needed code Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Engine/QueryParameters.cs Modified: trunk/nhibernate/src/NHibernate/Engine/QueryParameters.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Engine/QueryParameters.cs 2011-06-16 16:51:52 UTC (rev 5936) +++ trunk/nhibernate/src/NHibernate/Engine/QueryParameters.cs 2011-06-16 16:59:59 UTC (rev 5937) @@ -1,6 +1,7 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Linq; using NHibernate.Impl; using NHibernate.Param; using NHibernate.SqlCommand; @@ -22,12 +23,8 @@ private IType[] _positionalParameterTypes; private object[] _positionalParameterValues; - private int[] _positionalParameterLocations; private IDictionary<string, TypedValue> _namedParameters; private IDictionary<string, LockMode> _lockModes; - private IList<IType> filteredParameterTypes; - private IList<object> filteredParameterValues; - private IList<int> filteredParameterLocations; private RowSelection _rowSelection; private bool _cacheable; private string _cacheRegion; @@ -118,11 +115,6 @@ set { _positionalParameterTypes = value; } } - public int[] PositionalParameterLocations - { - get { return _positionalParameterLocations; } - } - /// <summary> /// Gets or sets an array of <see cref="object"/> objects that is stored at the index /// of the Parameter. @@ -284,11 +276,8 @@ var copy = new QueryParameters(_positionalParameterTypes, _positionalParameterValues, _namedParameters, _lockModes, selection, _isReadOnlyInitialized, _readOnly, _cacheable, _cacheRegion, _comment, _collectionKeys, _optionalObject, _optionalEntityName, _optionalId, _resultTransformer); - copy._positionalParameterLocations = _positionalParameterLocations; copy.processedSQL = processedSQL; - copy.filteredParameterTypes = filteredParameterTypes; - copy.filteredParameterValues = filteredParameterValues; - copy.filteredParameterLocations = filteredParameterLocations; + copy.ProcessedSqlParameters = ProcessedSqlParameters.ToList(); return copy; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2011-06-16 16:51:58
|
Revision: 5936 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5936&view=rev Author: fabiomaulo Date: 2011-06-16 16:51:52 +0000 (Thu, 16 Jun 2011) Log Message: ----------- Removed no more needed code Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Engine/QueryParameters.cs trunk/nhibernate/src/NHibernate/Engine/SubselectFetch.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Loader/QueryLoader.cs trunk/nhibernate/src/NHibernate/Hql/Classic/QueryTranslator.cs trunk/nhibernate/src/NHibernate/Loader/Criteria/CriteriaLoader.cs trunk/nhibernate/src/NHibernate/Loader/Loader.cs Modified: trunk/nhibernate/src/NHibernate/Engine/QueryParameters.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Engine/QueryParameters.cs 2011-06-16 16:41:01 UTC (rev 5935) +++ trunk/nhibernate/src/NHibernate/Engine/QueryParameters.cs 2011-06-16 16:51:52 UTC (rev 5936) @@ -270,29 +270,6 @@ public IEnumerable<IParameterSpecification> ProcessedSqlParameters { get; internal set; } - public SqlString FilteredSQL - { - get { return processedSQL; } - } - - public IList<IType> FilteredParameterTypes - { - get { return filteredParameterTypes; } - internal set { filteredParameterTypes = value; } - } - - public IList<object> FilteredParameterValues - { - get { return filteredParameterValues; } - internal set { filteredParameterValues = value; } - } - - public IList<int> FilteredParameterLocations - { - get { return filteredParameterLocations; } - internal set { filteredParameterLocations = value; } - } - public bool NaturalKeyLookup { get; set; } public IResultTransformer ResultTransformer Modified: trunk/nhibernate/src/NHibernate/Engine/SubselectFetch.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Engine/SubselectFetch.cs 2011-06-16 16:41:01 UTC (rev 5935) +++ trunk/nhibernate/src/NHibernate/Engine/SubselectFetch.cs 2011-06-16 16:51:52 UTC (rev 5936) @@ -24,7 +24,7 @@ this.loadable = loadable; this.alias = alias; - queryString = queryParameters.FilteredSQL.GetSubselectString(); + queryString = queryParameters.ProcessedSql.GetSubselectString(); } public QueryParameters QueryParameters Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Loader/QueryLoader.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Loader/QueryLoader.cs 2011-06-16 16:41:01 UTC (rev 5935) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Loader/QueryLoader.cs 2011-06-16 16:51:52 UTC (rev 5936) @@ -441,7 +441,7 @@ // dynamic-filter parameters: during the HQL->SQL parsing, filters can be added as SQL_TOKEN/string and the SqlGenerator will not find it sqlString = ExpandDynamicFilterParameters(sqlString, parameterSpecs, session); - AdjustQueryParametersForSubSelectFetching(sqlString, parameterSpecs, session, queryParameters); // NOTE: see TODO below + AdjustQueryParametersForSubSelectFetching(sqlString, parameterSpecs, queryParameters); // NOTE: see TODO below sqlString = AddLimitsParametersIfNeeded(sqlString, parameterSpecs, queryParameters, session); // TODO: for sub-select fetching we have to try to assign the QueryParameter.ProcessedSQL here (with limits) but only after use IParameterSpecification for any kind of queries and taking care about the work done by SubselectClauseExtractor Modified: trunk/nhibernate/src/NHibernate/Hql/Classic/QueryTranslator.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Classic/QueryTranslator.cs 2011-06-16 16:41:01 UTC (rev 5935) +++ trunk/nhibernate/src/NHibernate/Hql/Classic/QueryTranslator.cs 2011-06-16 16:51:52 UTC (rev 5936) @@ -309,7 +309,7 @@ // dynamic-filter parameters: during the HQL->SQL parsing, filters can be added as SQL_TOKEN/string and the SqlGenerator will not find it sql = ExpandDynamicFilterParameters(sql, parameterSpecs, session); - AdjustQueryParametersForSubSelectFetching(sql, parameterSpecs, session, queryParameters); // NOTE: see TODO below + AdjustQueryParametersForSubSelectFetching(sql, parameterSpecs, queryParameters); // NOTE: see TODO below sql = AddLimitsParametersIfNeeded(sql, parameterSpecs, queryParameters, session); // TODO: for sub-select fetching we have to try to assign the QueryParameter.ProcessedSQL here (with limits) but only after use IParameterSpecification for any kind of queries Modified: trunk/nhibernate/src/NHibernate/Loader/Criteria/CriteriaLoader.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Loader/Criteria/CriteriaLoader.cs 2011-06-16 16:41:01 UTC (rev 5935) +++ trunk/nhibernate/src/NHibernate/Loader/Criteria/CriteriaLoader.cs 2011-06-16 16:51:52 UTC (rev 5936) @@ -190,7 +190,7 @@ // dynamic-filter parameters: during the Criteria parsing, filters can be added as string. sqlString = ExpandDynamicFilterParameters(sqlString, parameterSpecs, session); - AdjustQueryParametersForSubSelectFetching(sqlString, parameterSpecs, session, queryParameters); // NOTE: see TODO below + AdjustQueryParametersForSubSelectFetching(sqlString, parameterSpecs, queryParameters); // NOTE: see TODO below sqlString = AddLimitsParametersIfNeeded(sqlString, parameterSpecs, queryParameters, session); // TODO: for sub-select fetching we have to try to assign the QueryParameter.ProcessedSQL here (with limits) but only after use IParameterSpecification for any kind of queries and taking care about the work done by SubselectClauseExtractor Modified: trunk/nhibernate/src/NHibernate/Loader/Loader.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Loader/Loader.cs 2011-06-16 16:41:01 UTC (rev 5935) +++ trunk/nhibernate/src/NHibernate/Loader/Loader.cs 2011-06-16 16:51:52 UTC (rev 5936) @@ -1686,7 +1686,7 @@ // dynamic-filter parameters: during the HQL->SQL parsing, filters can be added as SQL_TOKEN/string and the SqlGenerator will not find it sqlString = ExpandDynamicFilterParameters(sqlString, parameterSpecs, session); - AdjustQueryParametersForSubSelectFetching(sqlString, parameterSpecs, session, queryParameters); // NOTE: see TODO below + AdjustQueryParametersForSubSelectFetching(sqlString, parameterSpecs, queryParameters); // NOTE: see TODO below sqlString = AddLimitsParametersIfNeeded(sqlString, parameterSpecs, queryParameters, session); // TODO: for sub-select fetching we have to try to assign the QueryParameter.ProcessedSQL here (with limits) but only after use IParameterSpecification for any kind of queries and taking care about the work done by SubselectClauseExtractor @@ -1713,37 +1713,11 @@ return specifications; } - protected void AdjustQueryParametersForSubSelectFetching(SqlString sqlString, IEnumerable<IParameterSpecification> parameterSpecs, ISessionImplementor session, QueryParameters queryParameters) + protected void AdjustQueryParametersForSubSelectFetching(SqlString sqlString, IEnumerable<IParameterSpecification> parameterSpecs, QueryParameters queryParameters) { // TODO: Remove this when all parameters are managed using IParameterSpecification (QueryParameters does not need to have decomposed values for filters) - - var dynamicFilterParameterSpecifications = parameterSpecs.OfType<DynamicFilterParameterSpecification>().ToList(); - var filteredParameterValues = new List<object>(); - var filteredParameterTypes = new List<IType>(); - var filteredParameterLocations = new List<int>(); - - if (dynamicFilterParameterSpecifications.Count != 0) - { - var sqlQueryParametersList = sqlString.GetParameters().ToList(); - foreach (DynamicFilterParameterSpecification specification in dynamicFilterParameterSpecifications) - { - string backTrackId = specification.GetIdsForBackTrack(session.Factory).First(); - object value = session.GetFilterParameterValue(specification.FilterParameterFullName); - var elementType = specification.ExpectedType; - foreach (int position in sqlQueryParametersList.GetEffectiveParameterLocations(backTrackId)) - { - filteredParameterValues.Add(value); - filteredParameterTypes.Add(elementType); - filteredParameterLocations.Add(position); - } - } - } - queryParameters.ProcessedSql = sqlString; queryParameters.ProcessedSqlParameters = parameterSpecs.ToList(); - queryParameters.FilteredParameterLocations = filteredParameterLocations; - queryParameters.FilteredParameterTypes = filteredParameterTypes; - queryParameters.FilteredParameterValues = filteredParameterValues; } protected SqlString ExpandDynamicFilterParameters(SqlString sqlString, ICollection<IParameterSpecification> parameterSpecs, ISessionImplementor session) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2011-06-16 16:41:07
|
Revision: 5935 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5935&view=rev Author: fabiomaulo Date: 2011-06-16 16:41:01 +0000 (Thu, 16 Jun 2011) Log Message: ----------- Removed no more needed code Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Engine/QueryParameters.cs trunk/nhibernate/src/NHibernate/Loader/Loader.cs Modified: trunk/nhibernate/src/NHibernate/Engine/QueryParameters.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Engine/QueryParameters.cs 2011-06-16 16:30:10 UTC (rev 5934) +++ trunk/nhibernate/src/NHibernate/Engine/QueryParameters.cs 2011-06-16 16:41:01 UTC (rev 5935) @@ -1,14 +1,9 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Data; -using System.Linq; - -using NHibernate.Hql.Classic; using NHibernate.Impl; using NHibernate.Param; using NHibernate.SqlCommand; -using NHibernate.SqlTypes; using NHibernate.Transform; using NHibernate.Type; using NHibernate.Util; @@ -43,11 +38,6 @@ private bool _isReadOnlyInitialized; private string _comment; private bool _readOnly; - private int? limitParameterIndex = null; - private int? offsetParameterIndex = null; - private IDictionary<int, int> _adjustedParameterLocations; - private IDictionary<int, int> _tempPagingParameterIndexes; - private IDictionary<int, int> _pagingParameterIndexMap; private SqlString processedSQL; private readonly IResultTransformer _resultTransformer; @@ -62,7 +52,7 @@ } public QueryParameters(IType[] positionalParameterTypes, object[] postionalParameterValues) - : this(positionalParameterTypes, postionalParameterValues, null, null, false, false, false, null, null, false, null, null) {} + : this(positionalParameterTypes, postionalParameterValues, null, null, false, false, false, null, null, false, null) {} public QueryParameters(IType[] positionalParameterTypes, object[] postionalParameterValues, object[] collectionKeys) : this(positionalParameterTypes, postionalParameterValues, null, collectionKeys) {} @@ -70,11 +60,10 @@ public QueryParameters(IType[] positionalParameterTypes, object[] postionalParameterValues, IDictionary<string, TypedValue> namedParameters, object[] collectionKeys) : this(positionalParameterTypes, postionalParameterValues, namedParameters, null, null, false, false, false, null, null, collectionKeys, null) {} - public QueryParameters(IType[] positionalParameterTypes, object[] positionalParameterValues, IDictionary<string, LockMode> lockModes, RowSelection rowSelection, bool isReadOnlyInitialized, bool readOnly, bool cacheable, string cacheRegion, string comment, bool isLookupByNaturalKey, IResultTransformer transformer, IDictionary<int,int> tempPagingParameterIndexes) + public QueryParameters(IType[] positionalParameterTypes, object[] positionalParameterValues, IDictionary<string, LockMode> lockModes, RowSelection rowSelection, bool isReadOnlyInitialized, bool readOnly, bool cacheable, string cacheRegion, string comment, bool isLookupByNaturalKey, IResultTransformer transformer) : this(positionalParameterTypes, positionalParameterValues, null, lockModes, rowSelection, isReadOnlyInitialized, readOnly, cacheable, cacheRegion, comment, null, transformer) { NaturalKeyLookup = isLookupByNaturalKey; - _tempPagingParameterIndexes = tempPagingParameterIndexes; } public QueryParameters(IDictionary<string, TypedValue> namedParameters, IDictionary<string, LockMode> lockModes, RowSelection rowSelection, bool isReadOnlyInitialized, bool readOnly, bool cacheable, string cacheRegion, string comment, bool isLookupByNaturalKey, IResultTransformer transformer) @@ -113,16 +102,6 @@ get { return _rowSelection != null; } } - public int? LimitParameterIndex - { - get { return limitParameterIndex; } - } - - public int? OffsetParameterIndex - { - get { return offsetParameterIndex; } - } - public IDictionary<string, TypedValue> NamedParameters { get { return _namedParameters; } @@ -178,18 +157,6 @@ { get { return _isReadOnlyInitialized; } } - - private void CreatePositionalParameterLocations(ISessionFactoryImplementor factory) - { - _positionalParameterLocations = new int[_positionalParameterTypes.Length]; - int location = 0; - for (int i = 0; i < _positionalParameterLocations.Length; i++) - { - var span = _positionalParameterTypes[i].GetColumnSpan(factory); - _positionalParameterLocations[i] = location; - location += span; - } - } private int SafeLength(Array array) { @@ -295,351 +262,6 @@ } } - /************** Filters ********************************/ - - public int FindAdjustedParameterLocation(int parameterIndex) - { - if (_adjustedParameterLocations == null) - return parameterIndex; - - return _adjustedParameterLocations[parameterIndex]; - } - - public void ProcessFilters(SqlString sql, ISessionImplementor session) - { - filteredParameterValues = new List<object>(); - filteredParameterTypes = new List<IType>(); - filteredParameterLocations = new List<int>(); - - if (session.EnabledFilters.Count == 0 || sql.ToString().IndexOf(ParserHelper.HqlVariablePrefix) < 0) - { - processedSQL = sql.Copy(); - return; - } - - Dialect.Dialect dialect = session.Factory.Dialect; - string symbols = ParserHelper.HqlSeparators + dialect.OpenQuote + dialect.CloseQuote; - - var result = new SqlStringBuilder(); - - int originalParameterIndex = 0; // keep track of the positional parameter - int newParameterIndex = 0; - _adjustedParameterLocations = new Dictionary<int, int>(); - - foreach (var part in sql.Parts) - { - if (part is Parameter) - { - result.Add(((Parameter)part).Clone()); - - // (?) can be a position parameter or a named parameter (already substituted by (?), - // but only the positional parameters are available at this point. Adding them in the - // order of appearance is best that can be done at this point of time, but if they - // are mixed with named parameters, the order is still wrong, because values and - // types for the named parameters are added later to the end of the list. - // see test fixture NH-1098 - - _adjustedParameterLocations[originalParameterIndex] = newParameterIndex; - originalParameterIndex++; - newParameterIndex++; - continue; - } - - var tokenizer = new StringTokenizer((string) part, symbols, true); - - foreach (var token in tokenizer) - { - if (token.StartsWith(ParserHelper.HqlVariablePrefix)) - { - string filterParameterName = token.Substring(1); - object value = session.GetFilterParameterValue(filterParameterName); - IType type = session.GetFilterParameterType(filterParameterName); - - // If the value is not a value of the type but a collection of values... - if (value != null && !type.ReturnedClass.IsAssignableFrom(value.GetType()) && // Added to fix NH-882 - typeof (ICollection).IsAssignableFrom(value.GetType())) - { - var coll = (ICollection) value; - int i = 0; - foreach (var elementValue in coll) - { - i++; - int span = type.GetColumnSpan(session.Factory); - if (span > 0) - { - result.AddParameter(); - filteredParameterTypes.Add(type); - filteredParameterValues.Add(elementValue); - filteredParameterLocations.Add(newParameterIndex); - newParameterIndex++; - if (i < coll.Count) - { - result.Add(", "); - } - } - } - } - else - { - int span = type.GetColumnSpan(session.Factory); - if (span > 0) - { - result.AddParameter(); - filteredParameterTypes.Add(type); - filteredParameterValues.Add(value); - filteredParameterLocations.Add(newParameterIndex); - newParameterIndex++; - } - } - } - else - { - result.Add(token); - } - } - } - - processedSQL = result.ToSqlString(); - } - - private IList<Parameter> FindParametersIn(SqlString sqlString) - { - IList<Parameter> sqlParameters = new List<Parameter>(); - - foreach (object sqlParameter in sqlString.Parts) - { - if (sqlParameter is Parameter) - { - var parameter = (Parameter) sqlParameter; - if (!parameter.ParameterPosition.HasValue || (parameter.ParameterPosition >= 0)) - { - sqlParameters.Add(parameter); - } - } - } - - return sqlParameters; - } - - private void SetParameterLocation(IList<Parameter> sqlParameters, int parameterIndex, int sqlLocation, int span) - { - int i = 0; - while (i < span) - { - sqlParameters[sqlLocation + i].ParameterPosition = parameterIndex + i; - i++; - } - } - - private SqlType[] ConvertITypesToSqlTypes(List<IType> nhTypes, ISessionFactoryImplementor factory, int totalSpan) - { - SqlType[] result = new SqlType[totalSpan]; - - int index = 0; - foreach (IType type in nhTypes) - { - int span = type.SqlTypes(factory).Length; - Array.Copy(type.SqlTypes(factory), 0, result, index, span); - index += span; - } - - return result; - } - - public SqlType[] PrepareParameterTypes(SqlString sqlString, ISessionFactoryImplementor factory, GetNamedParameterLocations getNamedParameterLocations, int startParameterIndex, bool addLimit, bool addOffset) - { - List<IType> paramTypeList = new List<IType>(); - int parameterIndex = 0; - int totalSpan = 0; - - CreatePositionalParameterLocations(factory); - - IList<Parameter> sqlParameters = FindParametersIn(sqlString); - - for (int index = 0; index < PositionalParameterTypes.Length; index++) - { - IType type = PositionalParameterTypes[index]; - ArrayHelper.SafeSetValue(paramTypeList, parameterIndex, type); - - int location = PositionalParameterLocations[index]; - location = FindAdjustedParameterLocation(location); - int span = type.GetColumnSpan(factory); - SetParameterLocation(sqlParameters, startParameterIndex + totalSpan, location, span); - - totalSpan += span; - parameterIndex++; - } - - for (int index = 0; index < FilteredParameterTypes.Count; index++) - { - IType type = FilteredParameterTypes[index]; - ArrayHelper.SafeSetValue(paramTypeList, parameterIndex, type); - - int location = FilteredParameterLocations[index]; - int span = type.GetColumnSpan(factory); - SetParameterLocation(sqlParameters, startParameterIndex + totalSpan, location, span); - - totalSpan += span; - parameterIndex++; - } - - if (NamedParameters != null && NamedParameters.Count > 0) - { - // convert the named parameters to an array of types - foreach (KeyValuePair<string, TypedValue> namedParameter in NamedParameters) - { - TypedValue typedval = namedParameter.Value; - ArrayHelper.SafeSetValue(paramTypeList, parameterIndex, typedval.Type); - - int span = typedval.Type.GetColumnSpan(factory); - string name = namedParameter.Key; - int[] locs = getNamedParameterLocations(name); - for (int i = 0; i < locs.Length; i++) - { - int location = locs[i]; - location = FindAdjustedParameterLocation(location); - - // can still clash with positional parameters - // could consider throwing an exception to locate problem (NH-1098) - while ((location < sqlParameters.Count) && (sqlParameters[location].ParameterPosition != null)) - location++; - - SetParameterLocation(sqlParameters, startParameterIndex + totalSpan, location, span); - } - - totalSpan += span; - parameterIndex++; - } - } - - if (_tempPagingParameterIndexes != null) - { - _pagingParameterIndexMap = new Dictionary<int, int>(); - - var pagingParameters = - sqlString.Parts - .Cast<object>() - .Where(p => p is Parameter) - .Cast<Parameter>() - .Where(p => p.ParameterPosition.HasValue && p.ParameterPosition < 0) - .ToList(); - - foreach (Parameter pagingParameter in pagingParameters) - { - int pagingValue = _tempPagingParameterIndexes[pagingParameter.ParameterPosition.Value]; - int position = parameterIndex + startParameterIndex; - _pagingParameterIndexMap.Add(position, pagingValue); - pagingParameter.ParameterPosition = position; - paramTypeList.Add(NHibernateUtil.Int32); - parameterIndex++; - totalSpan++; - } - } - - if (addLimit && factory.Dialect.SupportsVariableLimit) - { - if (factory.Dialect.BindLimitParametersFirst) - { - paramTypeList.Insert(0, NHibernateUtil.Int32); - limitParameterIndex = startParameterIndex - 1; - if (addOffset) - { - paramTypeList.Insert(0, NHibernateUtil.Int32); - offsetParameterIndex = startParameterIndex - 2; - } - } - else - { - paramTypeList.Add(NHibernateUtil.Int32); - limitParameterIndex = startParameterIndex + totalSpan; - if (addOffset) - { - paramTypeList.Add(NHibernateUtil.Int32); - offsetParameterIndex = startParameterIndex + totalSpan; - limitParameterIndex = startParameterIndex + totalSpan + 1; - } - } - - if (addOffset && factory.Dialect.BindLimitParametersInReverseOrder) - { - int? temp = limitParameterIndex; - limitParameterIndex = offsetParameterIndex; - offsetParameterIndex = temp; - } - - totalSpan += addOffset ? 2 : 1; - } - - return ConvertITypesToSqlTypes(paramTypeList, factory, totalSpan); - } - - public int BindParameters(IDbCommand command, int start, ISessionImplementor session) - { - int location = start; - var values = new List<object>(); - var types = new List<IType>(); - var sources = new List<string>(); - - for (int i = 0; i < _positionalParameterLocations.Length; i++) - { - object value = _positionalParameterValues[i]; - IType type = _positionalParameterTypes[i]; - ArrayHelper.SafeSetValue(values, location, value); - ArrayHelper.SafeSetValue(types, location, type); - ArrayHelper.SafeSetValue(sources, location, "Positional" + i); - location++; - } - - for (int i = 0; i < filteredParameterLocations.Count; i++) - { - object value = filteredParameterValues[i]; - IType type = filteredParameterTypes[i]; - ArrayHelper.SafeSetValue(values, location, value); - ArrayHelper.SafeSetValue(types, location, type); - ArrayHelper.SafeSetValue(sources, location, "Filter" + i); - location++; - } - - if ((_namedParameters != null) && (_namedParameters.Count > 0)) - { - foreach (var namedParameter in _namedParameters) - { - string name = namedParameter.Key; - TypedValue typedval = namedParameter.Value; - ArrayHelper.SafeSetValue(values, location, typedval.Value); - ArrayHelper.SafeSetValue(types, location, typedval.Type); - ArrayHelper.SafeSetValue(sources, location, "name_" + name); - location++; - } - } - - if (_pagingParameterIndexMap != null) - { - foreach (int pagingParameterIndex in _pagingParameterIndexMap.Keys) - { - ArrayHelper.SafeSetValue(values, pagingParameterIndex, _pagingParameterIndexMap[pagingParameterIndex]); - ArrayHelper.SafeSetValue(types, pagingParameterIndex, NHibernateUtil.Int32); - ArrayHelper.SafeSetValue(sources, pagingParameterIndex, "limit_" + pagingParameterIndex); - } - } - - int span = 0; - for (int i = start; i < values.Count; i++) - { - IType type = types[i]; - object value = values[i]; - string source = sources[i]; - if (log.IsDebugEnabled) - { - log.Debug(string.Format("BindParameters({0}:{1}) {2} -> [{3}]", source, type, value, i)); - } - type.NullSafeSet(command, value, start + span, session); - span += type.GetColumnSpan(session.Factory); - } - - return span; - } - public SqlString ProcessedSql { get { return processedSQL; } Modified: trunk/nhibernate/src/NHibernate/Loader/Loader.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Loader/Loader.cs 2011-06-16 16:30:10 UTC (rev 5934) +++ trunk/nhibernate/src/NHibernate/Loader/Loader.cs 2011-06-16 16:41:01 UTC (rev 5935) @@ -1170,12 +1170,6 @@ return command; } - protected virtual SqlString ProcessFilters(QueryParameters parameters, ISessionImplementor session) - { - parameters.ProcessFilters(SqlString, session); - return parameters.FilteredSQL; - } - /// <summary> /// Some dialect-specific LIMIT clauses require the maximium last row number /// (aka, first_row_number + total_row_count), while others require the maximum @@ -1246,23 +1240,6 @@ //} } - /// <summary> - /// Bind all parameter values into the prepared statement in preparation for execution. - /// </summary> - /// <param name="statement">The ADO prepared statement </param> - /// <param name="queryParameters">The encapsulation of the parameter values to be bound. </param> - /// <param name="startIndex">The position from which to start binding parameter values. </param> - /// <param name="session">The originating session. </param> - /// <returns> The number of ADO bind positions actually bound during this method execution. </returns> - protected virtual int BindParameterValues(IDbCommand statement, QueryParameters queryParameters, - int startIndex, ISessionImplementor session) - { - // NH Different behavior: - // The responsibility of parameter binding was entirely moved to QueryParameters - // to deal with positionslParameter+NamedParameter+ParameterOfFilters - return queryParameters.BindParameters(statement, startIndex, session); - } - public virtual int[] GetNamedParameterLocs(string name) { throw new AssertionFailure("no named parameters"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2011-06-16 16:30:16
|
Revision: 5934 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5934&view=rev Author: fabiomaulo Date: 2011-06-16 16:30:10 +0000 (Thu, 16 Jun 2011) Log Message: ----------- Adjusted TODO Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Loader/QueryLoader.cs trunk/nhibernate/src/NHibernate/Loader/Criteria/CriteriaLoader.cs trunk/nhibernate/src/NHibernate/Loader/Custom/CustomLoader.cs Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Loader/QueryLoader.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Loader/QueryLoader.cs 2011-06-16 16:29:39 UTC (rev 5933) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Loader/QueryLoader.cs 2011-06-16 16:30:10 UTC (rev 5934) @@ -444,7 +444,7 @@ AdjustQueryParametersForSubSelectFetching(sqlString, parameterSpecs, session, queryParameters); // NOTE: see TODO below sqlString = AddLimitsParametersIfNeeded(sqlString, parameterSpecs, queryParameters, session); - // TODO: for sub-select fetching we have to try to assign the QueryParameter.ProcessedSQL here (with limits) but only after use IParameterSpecification for any kind of queries + // TODO: for sub-select fetching we have to try to assign the QueryParameter.ProcessedSQL here (with limits) but only after use IParameterSpecification for any kind of queries and taking care about the work done by SubselectClauseExtractor // The PreprocessSQL method can modify the SqlString but should never add parameters (or we have to override it) sqlString = PreprocessSQL(sqlString, queryParameters, session.Factory.Dialect); Modified: trunk/nhibernate/src/NHibernate/Loader/Criteria/CriteriaLoader.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Loader/Criteria/CriteriaLoader.cs 2011-06-16 16:29:39 UTC (rev 5933) +++ trunk/nhibernate/src/NHibernate/Loader/Criteria/CriteriaLoader.cs 2011-06-16 16:30:10 UTC (rev 5934) @@ -193,7 +193,7 @@ AdjustQueryParametersForSubSelectFetching(sqlString, parameterSpecs, session, queryParameters); // NOTE: see TODO below sqlString = AddLimitsParametersIfNeeded(sqlString, parameterSpecs, queryParameters, session); - // TODO: for sub-select fetching we have to try to assign the QueryParameter.ProcessedSQL here (with limits) but only after use IParameterSpecification for any kind of queries + // TODO: for sub-select fetching we have to try to assign the QueryParameter.ProcessedSQL here (with limits) but only after use IParameterSpecification for any kind of queries and taking care about the work done by SubselectClauseExtractor // The PreprocessSQL method can modify the SqlString but should never add parameters (or we have to override it) sqlString = PreprocessSQL(sqlString, queryParameters, session.Factory.Dialect); Modified: trunk/nhibernate/src/NHibernate/Loader/Custom/CustomLoader.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Loader/Custom/CustomLoader.cs 2011-06-16 16:29:39 UTC (rev 5933) +++ trunk/nhibernate/src/NHibernate/Loader/Custom/CustomLoader.cs 2011-06-16 16:30:10 UTC (rev 5934) @@ -354,7 +354,7 @@ //AdjustQueryParametersForSubSelectFetching(sqlString, parameterSpecs, session, queryParameters); // NOTE: see TODO below sqlString = AddLimitsParametersIfNeeded(sqlString, parameterSpecs, queryParameters, session); - // TODO: for sub-select fetching we have to try to assign the QueryParameter.ProcessedSQL here (with limits) but only after use IParameterSpecification for any kind of queries + // TODO: for sub-select fetching we have to try to assign the QueryParameter.ProcessedSQL here (with limits) but only after use IParameterSpecification for any kind of queries and taking care about the work done by SubselectClauseExtractor // The PreprocessSQL method can modify the SqlString but should never add parameters (or we have to override it) sqlString = PreprocessSQL(sqlString, queryParameters, session.Factory.Dialect); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2011-06-16 16:29:46
|
Revision: 5933 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5933&view=rev Author: fabiomaulo Date: 2011-06-16 16:29:39 +0000 (Thu, 16 Jun 2011) Log Message: ----------- Added parameter-specifications for sub-select queries Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Engine/QueryParameters.cs trunk/nhibernate/src/NHibernate/Loader/Collection/SubselectCollectionLoader.cs trunk/nhibernate/src/NHibernate/Loader/Collection/SubselectOneToManyLoader.cs trunk/nhibernate/src/NHibernate/Loader/Loader.cs Modified: trunk/nhibernate/src/NHibernate/Engine/QueryParameters.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Engine/QueryParameters.cs 2011-06-15 23:31:17 UTC (rev 5932) +++ trunk/nhibernate/src/NHibernate/Engine/QueryParameters.cs 2011-06-16 16:29:39 UTC (rev 5933) @@ -6,6 +6,7 @@ using NHibernate.Hql.Classic; using NHibernate.Impl; +using NHibernate.Param; using NHibernate.SqlCommand; using NHibernate.SqlTypes; using NHibernate.Transform; @@ -639,12 +640,14 @@ return span; } - internal SqlString ProcessedSql + public SqlString ProcessedSql { get { return processedSQL; } - set { processedSQL = value; } + internal set { processedSQL = value; } } + public IEnumerable<IParameterSpecification> ProcessedSqlParameters { get; internal set; } + public SqlString FilteredSQL { get { return processedSQL; } Modified: trunk/nhibernate/src/NHibernate/Loader/Collection/SubselectCollectionLoader.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Loader/Collection/SubselectCollectionLoader.cs 2011-06-15 23:31:17 UTC (rev 5932) +++ trunk/nhibernate/src/NHibernate/Loader/Collection/SubselectCollectionLoader.cs 2011-06-16 16:29:39 UTC (rev 5933) @@ -1,5 +1,7 @@ using System.Collections.Generic; +using System.Linq; using NHibernate.Engine; +using NHibernate.Param; using NHibernate.Persister.Collection; using NHibernate.SqlCommand; using NHibernate.Type; @@ -14,6 +16,7 @@ private readonly IDictionary<string, TypedValue> namedParameters; private readonly IType[] types; private readonly object[] values; + private readonly List<IParameterSpecification> parametersSpecifications; public SubselectCollectionLoader(IQueryableCollection persister, SqlString subquery, ICollection<EntityKey> entityKeys, QueryParameters queryParameters, IDictionary<string, int[]> namedParameterLocMap, @@ -28,7 +31,9 @@ } namedParameters = queryParameters.NamedParameters; + // NH Different behavior: to deal with positionslParameter+NamedParameter+ParameterOfFilters + parametersSpecifications = queryParameters.ProcessedSqlParameters.ToList(); types = queryParameters.PositionalParameterTypes; values = queryParameters.PositionalParameterValues; this.namedParameterLocMap = namedParameterLocMap; @@ -43,5 +48,10 @@ { return namedParameterLocMap[name]; } + + protected override IEnumerable<IParameterSpecification> GetParameterSpecifications(QueryParameters queryParameters, ISessionFactoryImplementor sessionFactory) + { + return parametersSpecifications; + } } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Loader/Collection/SubselectOneToManyLoader.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Loader/Collection/SubselectOneToManyLoader.cs 2011-06-15 23:31:17 UTC (rev 5932) +++ trunk/nhibernate/src/NHibernate/Loader/Collection/SubselectOneToManyLoader.cs 2011-06-16 16:29:39 UTC (rev 5933) @@ -1,5 +1,7 @@ using System.Collections.Generic; +using System.Linq; using NHibernate.Engine; +using NHibernate.Param; using NHibernate.Persister.Collection; using NHibernate.SqlCommand; using NHibernate.Type; @@ -17,6 +19,7 @@ private readonly IDictionary<string, TypedValue> namedParameters; private readonly IType[] types; private readonly object[] values; + private readonly List<IParameterSpecification> parametersSpecifications; public SubselectOneToManyLoader(IQueryableCollection persister, SqlString subquery, ICollection<EntityKey> entityKeys, QueryParameters queryParameters, IDictionary<string, int[]> namedParameterLocMap, @@ -32,8 +35,9 @@ namedParameters = queryParameters.NamedParameters; // NH Different behavior: to deal with positionslParameter+NamedParameter+ParameterOfFilters - types = new List<IType>(new JoinedEnumerable<IType>(queryParameters.FilteredParameterTypes, queryParameters.PositionalParameterTypes)).ToArray(); - values = new List<object>(new JoinedEnumerable<object>(queryParameters.FilteredParameterValues, queryParameters.PositionalParameterValues)).ToArray(); + parametersSpecifications = queryParameters.ProcessedSqlParameters.ToList(); + types = queryParameters.PositionalParameterTypes; + values = queryParameters.PositionalParameterValues; this.namedParameterLocMap = namedParameterLocMap; } @@ -46,5 +50,10 @@ { return namedParameterLocMap[name]; } + + protected override IEnumerable<IParameterSpecification> GetParameterSpecifications(QueryParameters queryParameters, ISessionFactoryImplementor sessionFactory) + { + return parametersSpecifications; + } } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Loader/Loader.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Loader/Loader.cs 2011-06-15 23:31:17 UTC (rev 5932) +++ trunk/nhibernate/src/NHibernate/Loader/Loader.cs 2011-06-16 16:29:39 UTC (rev 5933) @@ -1712,7 +1712,7 @@ AdjustQueryParametersForSubSelectFetching(sqlString, parameterSpecs, session, queryParameters); // NOTE: see TODO below sqlString = AddLimitsParametersIfNeeded(sqlString, parameterSpecs, queryParameters, session); - // TODO: for sub-select fetching we have to try to assign the QueryParameter.ProcessedSQL here (with limits) but only after use IParameterSpecification for any kind of queries + // TODO: for sub-select fetching we have to try to assign the QueryParameter.ProcessedSQL here (with limits) but only after use IParameterSpecification for any kind of queries and taking care about the work done by SubselectClauseExtractor // The PreprocessSQL method can modify the SqlString but should never add parameters (or we have to override it) sqlString = PreprocessSQL(sqlString, queryParameters, session.Factory.Dialect); @@ -1720,7 +1720,7 @@ return new SqlCommandImpl(sqlString, parameterSpecs, queryParameters, session.Factory); } - protected IEnumerable<IParameterSpecification> GetParameterSpecifications(QueryParameters queryParameters, ISessionFactoryImplementor sessionFactory) + protected virtual IEnumerable<IParameterSpecification> GetParameterSpecifications(QueryParameters queryParameters, ISessionFactoryImplementor sessionFactory) { // TODO FM: remove this implementation and put an abstract ParameterSpecifications in the Loader (each concrete implementation have to expose it) => NH1990, SubselectFetchFixture var positionalSpecifications = queryParameters.PositionalParameterTypes.Select((t, i) => (IParameterSpecification)new PositionalParameterSpecification(1, 0, i) { ExpectedType = t }); @@ -1763,6 +1763,7 @@ } queryParameters.ProcessedSql = sqlString; + queryParameters.ProcessedSqlParameters = parameterSpecs.ToList(); queryParameters.FilteredParameterLocations = filteredParameterLocations; queryParameters.FilteredParameterTypes = filteredParameterTypes; queryParameters.FilteredParameterValues = filteredParameterValues; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2011-06-15 23:31:24
|
Revision: 5932 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5932&view=rev Author: fabiomaulo Date: 2011-06-15 23:31:17 +0000 (Wed, 15 Jun 2011) Log Message: ----------- Refactoring to have common PrepareQueryCommand (as before) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Loader/QueryLoader.cs trunk/nhibernate/src/NHibernate/Hql/Classic/QueryTranslator.cs trunk/nhibernate/src/NHibernate/Impl/MultiQueryImpl.cs trunk/nhibernate/src/NHibernate/Loader/Criteria/CriteriaLoader.cs trunk/nhibernate/src/NHibernate/Loader/Custom/CustomLoader.cs trunk/nhibernate/src/NHibernate/Loader/Custom/ICustomQuery.cs trunk/nhibernate/src/NHibernate/Loader/Loader.cs Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Loader/QueryLoader.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Loader/QueryLoader.cs 2011-06-15 20:04:47 UTC (rev 5931) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Loader/QueryLoader.cs 2011-06-15 23:31:17 UTC (rev 5932) @@ -454,51 +454,5 @@ return new SqlCommandImpl(sqlString, parameterSpecs, queryParameters, session.Factory); } - - /// <summary> - /// Obtain an <c>IDbCommand</c> with all parameters pre-bound. Bind positional parameters, - /// named parameters, and limit parameters. - /// </summary> - /// <remarks> - /// Creates an IDbCommand object and populates it with the values necessary to execute it against the - /// database to Load an Entity. - /// </remarks> - /// <param name="queryParameters">The <see cref="QueryParameters"/> to use for the IDbCommand.</param> - /// <param name="scroll">TODO: find out where this is used...</param> - /// <param name="session">The SessionImpl this Command is being prepared in.</param> - /// <returns>A CommandWrapper wrapping an IDbCommand that is ready to be executed.</returns> - protected internal override IDbCommand PrepareQueryCommand(QueryParameters queryParameters, bool scroll, ISessionImplementor session) - { - var sqlCommand = CreateSqlCommand(queryParameters, session); - var sqlString = sqlCommand.Query; - - sqlCommand.ResetParametersIndexesForTheCommand(0); - IDbCommand command = session.Batcher.PrepareQueryCommand(CommandType.Text, sqlString, sqlCommand.ParameterTypes); - - try - { - RowSelection selection = queryParameters.RowSelection; - if (selection != null && selection.Timeout != RowSelection.NoValue) - { - command.CommandTimeout = selection.Timeout; - } - - sqlCommand.Bind(command, session); - - session.Batcher.ExpandQueryParameters(command, sqlString); - } - catch (HibernateException) - { - session.Batcher.CloseCommand(command, null); - throw; - } - catch (Exception sqle) - { - session.Batcher.CloseCommand(command, null); - ADOExceptionReporter.LogExceptions(sqle); - throw; - } - return command; - } } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Hql/Classic/QueryTranslator.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Classic/QueryTranslator.cs 2011-06-15 20:04:47 UTC (rev 5931) +++ trunk/nhibernate/src/NHibernate/Hql/Classic/QueryTranslator.cs 2011-06-15 23:31:17 UTC (rev 5932) @@ -324,52 +324,6 @@ } /// <summary> - /// Obtain an <c>IDbCommand</c> with all parameters pre-bound. Bind positional parameters, - /// named parameters, and limit parameters. - /// </summary> - /// <remarks> - /// Creates an IDbCommand object and populates it with the values necessary to execute it against the - /// database to Load an Entity. - /// </remarks> - /// <param name="queryParameters">The <see cref="QueryParameters"/> to use for the IDbCommand.</param> - /// <param name="scroll">TODO: find out where this is used...</param> - /// <param name="session">The SessionImpl this Command is being prepared in.</param> - /// <returns>A CommandWrapper wrapping an IDbCommand that is ready to be executed.</returns> - protected internal override IDbCommand PrepareQueryCommand(QueryParameters queryParameters, bool scroll, ISessionImplementor session) - { - var sqlCommand = CreateSqlCommand(queryParameters, session); - var query = sqlCommand.Query; - - sqlCommand.ResetParametersIndexesForTheCommand(0); - IDbCommand command = session.Batcher.PrepareQueryCommand(CommandType.Text, query, sqlCommand.ParameterTypes); - - try - { - RowSelection selection = queryParameters.RowSelection; - if (selection != null && selection.Timeout != RowSelection.NoValue) - { - command.CommandTimeout = selection.Timeout; - } - - sqlCommand.Bind(command, session); - - session.Batcher.ExpandQueryParameters(command, query); - } - catch (HibernateException) - { - session.Batcher.CloseCommand(command, null); - throw; - } - catch (Exception sqle) - { - session.Batcher.CloseCommand(command, null); - ADOExceptionReporter.LogExceptions(sqle); - throw; - } - return command; - } - - /// <summary> /// Compile a "normal" query. This method may be called multiple /// times. Subsequent invocations are no-ops. /// </summary> Modified: trunk/nhibernate/src/NHibernate/Impl/MultiQueryImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/MultiQueryImpl.cs 2011-06-15 20:04:47 UTC (rev 5931) +++ trunk/nhibernate/src/NHibernate/Impl/MultiQueryImpl.cs 2011-06-15 23:31:17 UTC (rev 5932) @@ -865,7 +865,7 @@ var sqlQueryImpl = (SqlQueryImpl) sqlQuery; NativeSQLQuerySpecification sqlQuerySpec = sqlQueryImpl.GenerateQuerySpecification(sqlQueryImpl.NamedParams); var sqlCustomQuery = new SQLCustomQuery(sqlQuerySpec.SqlQueryReturns, sqlQuerySpec.QueryString, sqlQuerySpec.QuerySpaces, sessionFactory); - loader = new CustomLoader(sqlCustomQuery, sqlCustomQuery.CollectedParametersSpecifications, sessionFactory); + loader = new CustomLoader(sqlCustomQuery, sessionFactory); } public IType[] ReturnTypes Modified: trunk/nhibernate/src/NHibernate/Loader/Criteria/CriteriaLoader.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Loader/Criteria/CriteriaLoader.cs 2011-06-15 20:04:47 UTC (rev 5931) +++ trunk/nhibernate/src/NHibernate/Loader/Criteria/CriteriaLoader.cs 2011-06-15 23:31:17 UTC (rev 5932) @@ -201,52 +201,6 @@ return new SqlCommandImpl(sqlString, parameterSpecs, queryParameters, session.Factory); } - /// <summary> - /// Obtain an <c>IDbCommand</c> with all parameters pre-bound. Bind positional parameters, - /// named parameters, and limit parameters. - /// </summary> - /// <remarks> - /// Creates an IDbCommand object and populates it with the values necessary to execute it against the - /// database to Load an Entity. - /// </remarks> - /// <param name="queryParameters">The <see cref="QueryParameters"/> to use for the IDbCommand.</param> - /// <param name="scroll">TODO: find out where this is used...</param> - /// <param name="session">The SessionImpl this Command is being prepared in.</param> - /// <returns>A CommandWrapper wrapping an IDbCommand that is ready to be executed.</returns> - protected internal override IDbCommand PrepareQueryCommand(QueryParameters queryParameters, bool scroll, ISessionImplementor session) - { - var sqlCommand = CreateSqlCommand(queryParameters, session); - var sqlString = sqlCommand.Query; - - sqlCommand.ResetParametersIndexesForTheCommand(0); - IDbCommand command = session.Batcher.PrepareQueryCommand(CommandType.Text, sqlString, sqlCommand.ParameterTypes); - - try - { - RowSelection selection = queryParameters.RowSelection; - if (selection != null && selection.Timeout != RowSelection.NoValue) - { - command.CommandTimeout = selection.Timeout; - } - - sqlCommand.Bind(command, session); - - session.Batcher.ExpandQueryParameters(command, sqlString); - } - catch (HibernateException) - { - session.Batcher.CloseCommand(command, null); - throw; - } - catch (Exception sqle) - { - session.Batcher.CloseCommand(command, null); - ADOExceptionReporter.LogExceptions(sqle); - throw; - } - return command; - } - public override int[] GetNamedParameterLocs(string name) { return new int[0]; Modified: trunk/nhibernate/src/NHibernate/Loader/Custom/CustomLoader.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Loader/Custom/CustomLoader.cs 2011-06-15 20:04:47 UTC (rev 5931) +++ trunk/nhibernate/src/NHibernate/Loader/Custom/CustomLoader.cs 2011-06-15 23:31:17 UTC (rev 5932) @@ -43,17 +43,12 @@ private IType[] resultTypes; private string[] transformerAliases; - public CustomLoader(ICustomQuery customQuery, IEnumerable<IParameterSpecification> parametersSpecifications, ISessionFactoryImplementor factory) - : this(customQuery, factory) - { - this.parametersSpecifications = parametersSpecifications.ToList(); - } - public CustomLoader(ICustomQuery customQuery, ISessionFactoryImplementor factory) : base(factory) { sql = customQuery.SQL; querySpaces.AddAll(customQuery.QuerySpaces); namedParameterBindPoints = customQuery.NamedParameterBindPoints; + this.parametersSpecifications = customQuery.CollectedParametersSpecifications.ToList(); List<IQueryable> entitypersisters = new List<IQueryable>(); List<int> entityowners = new List<int>(); @@ -350,10 +345,6 @@ public override ISqlCommand CreateSqlCommand(QueryParameters queryParameters, ISessionImplementor session) { - if(parametersSpecifications == null) - { - throw new InvalidOperationException("The custom SQL loader was not initialized with Parameters Specifications."); - } // A distinct-copy of parameter specifications collected during query construction var parameterSpecs = new HashSet<IParameterSpecification>(parametersSpecifications); SqlString sqlString = SqlString.Copy(); Modified: trunk/nhibernate/src/NHibernate/Loader/Custom/ICustomQuery.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Loader/Custom/ICustomQuery.cs 2011-06-15 20:04:47 UTC (rev 5931) +++ trunk/nhibernate/src/NHibernate/Loader/Custom/ICustomQuery.cs 2011-06-15 23:31:17 UTC (rev 5932) @@ -1,5 +1,6 @@ using System.Collections.Generic; using Iesi.Collections.Generic; +using NHibernate.Param; using NHibernate.SqlCommand; namespace NHibernate.Loader.Custom @@ -42,5 +43,7 @@ /// ADO result set to be expected and how to map this result set. /// </summary> IList<IReturn> CustomQueryReturns { get; } + + IEnumerable<IParameterSpecification> CollectedParametersSpecifications { get; } } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Loader/Loader.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Loader/Loader.cs 2011-06-15 20:04:47 UTC (rev 5931) +++ trunk/nhibernate/src/NHibernate/Loader/Loader.cs 2011-06-15 23:31:17 UTC (rev 5932) @@ -1136,83 +1136,25 @@ /// <param name="scroll">TODO: find out where this is used...</param> /// <param name="session">The SessionImpl this Command is being prepared in.</param> /// <returns>A CommandWrapper wrapping an IDbCommand that is ready to be executed.</returns> - protected internal virtual IDbCommand PrepareQueryCommand(QueryParameters queryParameters, bool scroll, - ISessionImplementor session) + protected internal virtual IDbCommand PrepareQueryCommand(QueryParameters queryParameters, bool scroll, ISessionImplementor session) { - SqlString sqlString = ProcessFilters(queryParameters, session); - Dialect.Dialect dialect = session.Factory.Dialect; + ISqlCommand sqlCommand = CreateSqlCommand(queryParameters, session); + SqlString sqlString = sqlCommand.Query; - RowSelection selection = queryParameters.RowSelection; - bool useLimit = UseLimit(selection, dialect); - bool hasFirstRow = GetFirstRow(selection) > 0; - bool useOffset = hasFirstRow && useLimit && dialect.SupportsLimitOffset; - int startIndex = GetFirstLimitParameterCount(dialect, useLimit, hasFirstRow, useOffset); - // TODO NH bool callable = queryParameters.Callable; + sqlCommand.ResetParametersIndexesForTheCommand(0); + IDbCommand command = session.Batcher.PrepareQueryCommand(CommandType.Text, sqlString, sqlCommand.ParameterTypes); - SqlType[] parameterTypes = queryParameters.PrepareParameterTypes(sqlString, Factory, GetNamedParameterLocs, startIndex, useLimit, useOffset); - - if (useLimit) - { - int? offset = GetOffsetUsingDialect(selection, dialect); - int? limit = GetLimitUsingDialect(selection, dialect); - Parameter offsetParameter = queryParameters.OffsetParameterIndex.HasValue ? Parameter.WithIndex(queryParameters.OffsetParameterIndex.Value) : null; - Parameter limitParameter = queryParameters.LimitParameterIndex.HasValue ? Parameter.WithIndex(queryParameters.LimitParameterIndex.Value) : null; - sqlString = - dialect.GetLimitString( - sqlString.Trim(), - useOffset ? offset : null, - limit, - useOffset ? offsetParameter : null, - limitParameter); - } - - sqlString = PreprocessSQL(sqlString, queryParameters, dialect); - - // TODO NH: Callable for SP -> PrepareCallableQueryCommand - IDbCommand command = - session.Batcher.PrepareQueryCommand(CommandType.Text, sqlString, parameterTypes); - try { - // Added in NH - not in H2.1 + RowSelection selection = queryParameters.RowSelection; if (selection != null && selection.Timeout != RowSelection.NoValue) { command.CommandTimeout = selection.Timeout; } - int colIndex = 0; + sqlCommand.Bind(command, session); - if (useLimit && dialect.BindLimitParametersFirst) - { - colIndex += BindLimitParameters(command, colIndex, selection, session); - } - // TODO NH - //if (callable) - //{ - // colIndex = dialect.RegisterResultSetOutParameter(command, col); - //} - - colIndex += BindParameterValues(command, queryParameters, colIndex, session); - - if (useLimit && !dialect.BindLimitParametersFirst) - { - BindLimitParameters(command, colIndex, selection, session); - } - session.Batcher.ExpandQueryParameters(command, sqlString); - - if (!useLimit) - { - SetMaxRows(command, selection); - } - if (selection != null) - { - if (selection.Timeout != RowSelection.NoValue) - { - command.CommandTimeout = selection.Timeout; - } - // H2.1 handles FetchSize here - not ported - } } catch (HibernateException) { @@ -1225,7 +1167,6 @@ ADOExceptionReporter.LogExceptions(sqle); throw; } - return command; } @@ -1758,9 +1699,43 @@ public virtual ISqlCommand CreateSqlCommand(QueryParameters queryParameters, ISessionImplementor session) { - throw new NotSupportedException("This loader does not support extraction of single command."); + // The implementation of this method is itended to be used just for "internal" command (not for queries coming from users) + // Internally NH creates various commands, all using just positional-parameters, to then potentially apply dynamic-filters and pagination. + // In practice this method should be overriden by those loaders representing a user-query as CriteriaLoader, QueryLoader, classic QueryTraslator, CustomLoader (for custmon SQL queries). + + // A distinct-copy of parameter specifications collected during query construction + var parameterSpecs = new HashSet<IParameterSpecification>(GetParameterSpecifications(queryParameters, session.Factory)); + SqlString sqlString = SqlString.Copy(); + + // dynamic-filter parameters: during the HQL->SQL parsing, filters can be added as SQL_TOKEN/string and the SqlGenerator will not find it + sqlString = ExpandDynamicFilterParameters(sqlString, parameterSpecs, session); + AdjustQueryParametersForSubSelectFetching(sqlString, parameterSpecs, session, queryParameters); // NOTE: see TODO below + + sqlString = AddLimitsParametersIfNeeded(sqlString, parameterSpecs, queryParameters, session); + // TODO: for sub-select fetching we have to try to assign the QueryParameter.ProcessedSQL here (with limits) but only after use IParameterSpecification for any kind of queries + + // The PreprocessSQL method can modify the SqlString but should never add parameters (or we have to override it) + sqlString = PreprocessSQL(sqlString, queryParameters, session.Factory.Dialect); + + return new SqlCommandImpl(sqlString, parameterSpecs, queryParameters, session.Factory); } + protected IEnumerable<IParameterSpecification> GetParameterSpecifications(QueryParameters queryParameters, ISessionFactoryImplementor sessionFactory) + { + // TODO FM: remove this implementation and put an abstract ParameterSpecifications in the Loader (each concrete implementation have to expose it) => NH1990, SubselectFetchFixture + var positionalSpecifications = queryParameters.PositionalParameterTypes.Select((t, i) => (IParameterSpecification)new PositionalParameterSpecification(1, 0, i) { ExpectedType = t }); + var namedSpecifications = queryParameters.NamedParameters != null ? queryParameters.NamedParameters.Select(np => (IParameterSpecification)new NamedParameterSpecification(1, 0, np.Key) { ExpectedType = np.Value.Type }): Enumerable.Empty<IParameterSpecification>(); + var specifications= positionalSpecifications.Concat(namedSpecifications).ToList(); + var parameters = SqlString.GetParameters().ToArray(); + var sqlParameterPos = 0; + var paramTrackers = specifications.SelectMany(specification => specification.GetIdsForBackTrack(sessionFactory)); + foreach (var paramTracker in paramTrackers) + { + parameters[sqlParameterPos++].BackTrack = paramTracker; + } + return specifications; + } + protected void AdjustQueryParametersForSubSelectFetching(SqlString sqlString, IEnumerable<IParameterSpecification> parameterSpecs, ISessionImplementor session, QueryParameters queryParameters) { // TODO: Remove this when all parameters are managed using IParameterSpecification (QueryParameters does not need to have decomposed values for filters) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2011-06-15 20:04:53
|
Revision: 5931 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5931&view=rev Author: fabiomaulo Date: 2011-06-15 20:04:47 +0000 (Wed, 15 Jun 2011) Log Message: ----------- Removed dead constructor Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Engine/QueryParameters.cs trunk/nhibernate/src/NHibernate/Loader/Criteria/CriteriaQueryTranslator.cs Modified: trunk/nhibernate/src/NHibernate/Engine/QueryParameters.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Engine/QueryParameters.cs 2011-06-15 19:38:45 UTC (rev 5930) +++ trunk/nhibernate/src/NHibernate/Engine/QueryParameters.cs 2011-06-15 20:04:47 UTC (rev 5931) @@ -52,8 +52,6 @@ public QueryParameters() : this(ArrayHelper.EmptyTypeArray, ArrayHelper.EmptyObjectArray) {} - public QueryParameters(IType type, object value) : this(new[] {type}, new[] {value}) {} - public QueryParameters(IType[] positionalParameterTypes, object[] postionalParameterValues, object optionalObject, string optionalEntityName, object optionalObjectId) : this(positionalParameterTypes, postionalParameterValues) { @@ -78,9 +76,10 @@ _tempPagingParameterIndexes = tempPagingParameterIndexes; } - public QueryParameters(IType[] positionalParameterTypes, object[] positionalParameterValues, IDictionary<string, TypedValue> namedParameters, IDictionary<string, LockMode> lockModes, RowSelection rowSelection, bool isReadOnlyInitialized, bool readOnly, bool cacheable, string cacheRegion, string comment, bool isLookupByNaturalKey, IResultTransformer transformer) - : this(positionalParameterTypes, positionalParameterValues, namedParameters, lockModes, rowSelection, isReadOnlyInitialized, readOnly, cacheable, cacheRegion, comment, null, transformer) + public QueryParameters(IDictionary<string, TypedValue> namedParameters, IDictionary<string, LockMode> lockModes, RowSelection rowSelection, bool isReadOnlyInitialized, bool readOnly, bool cacheable, string cacheRegion, string comment, bool isLookupByNaturalKey, IResultTransformer transformer) + : this(ArrayHelper.EmptyTypeArray, ArrayHelper.EmptyObjectArray, namedParameters, lockModes, rowSelection, isReadOnlyInitialized, readOnly, cacheable, cacheRegion, comment, null, transformer) { + // used by CriteriaTranslator NaturalKeyLookup = isLookupByNaturalKey; } Modified: trunk/nhibernate/src/NHibernate/Loader/Criteria/CriteriaQueryTranslator.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Loader/Criteria/CriteriaQueryTranslator.cs 2011-06-15 19:38:45 UTC (rev 5930) +++ trunk/nhibernate/src/NHibernate/Loader/Criteria/CriteriaQueryTranslator.cs 2011-06-15 20:04:47 UTC (rev 5931) @@ -134,8 +134,6 @@ return new QueryParameters( - new IType[0], - new object[0], queryNamedParameters, lockModes, selection, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2011-06-15 19:38:51
|
Revision: 5930 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5930&view=rev Author: fabiomaulo Date: 2011-06-15 19:38:45 +0000 (Wed, 15 Jun 2011) Log Message: ----------- Added influence of parameters names for multi queries Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Driver/BasicResultSetsCommand.cs Modified: trunk/nhibernate/src/NHibernate/Driver/BasicResultSetsCommand.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Driver/BasicResultSetsCommand.cs 2011-06-15 19:19:46 UTC (rev 5929) +++ trunk/nhibernate/src/NHibernate/Driver/BasicResultSetsCommand.cs 2011-06-15 19:38:45 UTC (rev 5930) @@ -43,6 +43,7 @@ { var batcher = Session.Batcher; SqlType[] sqlTypes = Commands.SelectMany(c => c.ParameterTypes).ToArray(); + ForEachSqlCommand((sqlLoaderCommand, offset) => sqlLoaderCommand.ResetParametersIndexesForTheCommand(offset)); var command = batcher.PrepareQueryCommand(CommandType.Text, sqlString, sqlTypes); if (commandTimeout.HasValue) { @@ -56,10 +57,19 @@ protected virtual void BindParameters(IDbCommand command) { var wholeQueryParametersList = Sql.GetParameters().ToList(); + ForEachSqlCommand((sqlLoaderCommand, offset) => sqlLoaderCommand.Bind(command, wholeQueryParametersList, offset, Session)); + } + + /// <summary> + /// Execute the given <paramref name="actionToDo"/> for each command of the resultset. + /// </summary> + /// <param name="actionToDo">The action to perform where the first parameter is the <see cref="ISqlCommand"/> and the second parameter is the parameters offset of the <see cref="ISqlCommand"/>.</param> + protected void ForEachSqlCommand(Action<ISqlCommand, int> actionToDo) + { var singleQueryParameterOffset = 0; foreach (var sqlLoaderCommand in Commands) { - sqlLoaderCommand.Bind(command, wholeQueryParametersList, singleQueryParameterOffset, Session); + actionToDo(sqlLoaderCommand, singleQueryParameterOffset); singleQueryParameterOffset += sqlLoaderCommand.ParameterTypes.Length; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |