|
From: <fab...@us...> - 2009-11-29 00:01:11
|
Revision: 4869
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4869&view=rev
Author: fabiomaulo
Date: 2009-11-29 00:00:57 +0000 (Sun, 29 Nov 2009)
Log Message:
-----------
Binders refactoring
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmClass.cs
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/JoinedSubclassBinder.cs
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/MappingRootBinder.cs
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/RootClassBinder.cs
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/SubclassBinder.cs
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/UnionSubclassBinder.cs
trunk/nhibernate/src/NHibernate/Mapping/Table.cs
trunk/nhibernate/src/NHibernate/NHibernate.csproj
trunk/nhibernate/src/NHibernate/Util/StringHelper.cs
Added Paths:
-----------
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmExtensions.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmJoinedSubclass.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmSubclass.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmUnionSubclass.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/IEntityDiscriminableMapping.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/IEntityMapping.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/IEntitySqlsMapping.cs
Removed Paths:
-------------
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/IEntityMetadata.cs
Modified: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmClass.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmClass.cs 2009-11-28 21:09:24 UTC (rev 4868)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmClass.cs 2009-11-29 00:00:57 UTC (rev 4869)
@@ -1,8 +1,6 @@
-using System;
-
namespace NHibernate.Cfg.MappingSchema
{
- partial class HbmClass: AbstractDecoratable
+ partial class HbmClass : AbstractDecoratable, IEntityMapping, IEntityDiscriminableMapping
{
public HbmId Id
{
@@ -24,9 +22,111 @@
get { return Item1 as HbmTimestamp; }
}
+ #region Implementation of IEntityMapping
+
protected override HbmMeta[] Metadatas
{
get { return meta ?? new HbmMeta[0]; }
}
+
+ public string EntityName
+ {
+ get { return entityname; }
+ }
+
+ public string Name
+ {
+ get { return name; }
+ }
+
+ public string Node
+ {
+ get { return node; }
+ }
+
+ public string Proxy
+ {
+ get { return proxy; }
+ }
+
+ public bool? UseLazy
+ {
+ get { return lazySpecified ? lazy : (bool?)null; }
+ }
+
+ public HbmTuplizer[] Tuplizers
+ {
+ get { return tuplizer ?? new HbmTuplizer[0]; }
+ }
+
+ public bool DynamicUpdate
+ {
+ get { return dynamicupdate; }
+ }
+
+ public bool DynamicInsert
+ {
+ get { return dynamicinsert; }
+ }
+
+ public int? BatchSize
+ {
+ get { return batchsizeSpecified ? batchsize : (int?) null; }
+ }
+
+ public bool SelectBeforeUpdate
+ {
+ get { return selectbeforeupdate; }
+ }
+
+ public string Persister
+ {
+ get { return persister; }
+ }
+
+ public bool? IsAbstract
+ {
+ get { return abstractSpecified ? @abstract : (bool?) null; }
+ }
+
+ public HbmSynchronize[] Synchronize
+ {
+ get { return synchronize ?? new HbmSynchronize[0]; }
+ }
+
+ #endregion
+
+ #region Implementation of IEntityDiscriminableMapping
+
+ public string DiscriminatorValue
+ {
+ get { return discriminatorvalue; }
+ }
+
+ #endregion
+
+ #region Implementation of IEntitySqlsMapping
+
+ public HbmLoader SqlLoader
+ {
+ get { return loader; }
+ }
+
+ public HbmCustomSQL SqlInsert
+ {
+ get { return sqlinsert; }
+ }
+
+ public HbmCustomSQL SqlUpdate
+ {
+ get { return sqlupdate; }
+ }
+
+ public HbmCustomSQL SqlDelete
+ {
+ get { return sqldelete; }
+ }
+
+ #endregion
}
}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmExtensions.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmExtensions.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmExtensions.cs 2009-11-29 00:00:57 UTC (rev 4869)
@@ -0,0 +1,25 @@
+using System;
+using NHibernate.Engine;
+
+namespace NHibernate.Cfg.MappingSchema
+{
+ public static class HbmExtensions
+ {
+ public static Versioning.OptimisticLock ToOptimisticLock(this HbmOptimisticLockMode hbmOptimisticLockMode)
+ {
+ switch (hbmOptimisticLockMode)
+ {
+ case HbmOptimisticLockMode.None:
+ return Versioning.OptimisticLock.None;
+ case HbmOptimisticLockMode.Version:
+ return Versioning.OptimisticLock.Version;
+ case HbmOptimisticLockMode.Dirty:
+ return Versioning.OptimisticLock.Dirty;
+ case HbmOptimisticLockMode.All:
+ return Versioning.OptimisticLock.All;
+ default:
+ return Versioning.OptimisticLock.Version;
+ }
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmJoinedSubclass.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmJoinedSubclass.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmJoinedSubclass.cs 2009-11-29 00:00:57 UTC (rev 4869)
@@ -0,0 +1,106 @@
+namespace NHibernate.Cfg.MappingSchema
+{
+ public partial class HbmJoinedSubclass : AbstractDecoratable, IEntityMapping
+ {
+ #region Overrides of AbstractDecoratable
+
+ protected override HbmMeta[] Metadatas
+ {
+ get { return meta ?? new HbmMeta[0]; }
+ }
+
+ #endregion
+
+ #region Implementation of IEntityMapping
+
+ public string EntityName
+ {
+ get { return entityname; }
+ }
+
+ public string Name
+ {
+ get { return name; }
+ }
+
+ public string Node
+ {
+ get { return node; }
+ }
+
+ public string Proxy
+ {
+ get { return proxy; }
+ }
+
+ public bool? UseLazy
+ {
+ get { return lazySpecified ? lazy : (bool?)null; }
+ }
+
+ public HbmTuplizer[] Tuplizers
+ {
+ get { return tuplizer ?? new HbmTuplizer[0]; }
+ }
+ public bool DynamicUpdate
+ {
+ get { return dynamicupdate; }
+ }
+
+ public bool DynamicInsert
+ {
+ get { return dynamicinsert; }
+ }
+
+ public int? BatchSize
+ {
+ get { return !string.IsNullOrEmpty(batchsize) ? int.Parse(batchsize) : (int?)null; }
+ }
+
+ public bool SelectBeforeUpdate
+ {
+ get { return selectbeforeupdate; }
+ }
+
+ public string Persister
+ {
+ get { return persister; }
+ }
+
+ public bool? IsAbstract
+ {
+ get { return abstractSpecified ? @abstract : (bool?)null; }
+ }
+
+ public HbmSynchronize[] Synchronize
+ {
+ get { return synchronize ?? new HbmSynchronize[0]; }
+ }
+
+ #endregion
+
+ #region Implementation of IEntitySqlsMapping
+
+ public HbmLoader SqlLoader
+ {
+ get { return loader; }
+ }
+
+ public HbmCustomSQL SqlInsert
+ {
+ get { return sqlinsert; }
+ }
+
+ public HbmCustomSQL SqlUpdate
+ {
+ get { return sqlupdate; }
+ }
+
+ public HbmCustomSQL SqlDelete
+ {
+ get { return sqldelete; }
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmSubclass.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmSubclass.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmSubclass.cs 2009-11-29 00:00:57 UTC (rev 4869)
@@ -0,0 +1,117 @@
+namespace NHibernate.Cfg.MappingSchema
+{
+ public partial class HbmSubclass : AbstractDecoratable, IEntityMapping, IEntityDiscriminableMapping
+ {
+ #region Overrides of AbstractDecoratable
+
+ protected override HbmMeta[] Metadatas
+ {
+ get { return meta ?? new HbmMeta[0]; }
+ }
+
+ #endregion
+
+ #region Implementation of IEntityMapping
+
+ public string EntityName
+ {
+ get { return entityname; }
+ }
+
+ public string Name
+ {
+ get { return name; }
+ }
+
+ public string Node
+ {
+ get { return node; }
+ }
+
+ public string Proxy
+ {
+ get { return proxy; }
+ }
+
+ public bool? UseLazy
+ {
+ get { return lazySpecified ? lazy : (bool?)null; }
+ }
+
+ public HbmTuplizer[] Tuplizers
+ {
+ get { return tuplizer ?? new HbmTuplizer[0]; }
+ }
+
+ public bool DynamicUpdate
+ {
+ get { return dynamicupdate; }
+ }
+
+ public bool DynamicInsert
+ {
+ get { return dynamicinsert; }
+ }
+
+ public int? BatchSize
+ {
+ get { return !string.IsNullOrEmpty(batchsize) ? int.Parse(batchsize) : (int?)null; }
+ }
+
+ public bool SelectBeforeUpdate
+ {
+ get { return selectbeforeupdate; }
+ }
+
+ public string Persister
+ {
+ get { return persister; }
+ }
+
+ public bool? IsAbstract
+ {
+ get { return abstractSpecified ? @abstract : (bool?)null; }
+ }
+
+ public HbmSynchronize[] Synchronize
+ {
+ get { return synchronize ?? new HbmSynchronize[0]; }
+ }
+
+ #endregion
+
+ #region Implementation of IEntityDiscriminableMapping
+
+ public string DiscriminatorValue
+ {
+ get { return discriminatorvalue; }
+ }
+
+ #endregion
+
+ #region Implementation of IEntitySqlsMapping
+
+ public HbmLoader SqlLoader
+ {
+ get { return loader; }
+ }
+
+ public HbmCustomSQL SqlInsert
+ {
+ get { return sqlinsert; }
+ }
+
+ public HbmCustomSQL SqlUpdate
+ {
+ get { return sqlupdate; }
+ }
+
+ public HbmCustomSQL SqlDelete
+ {
+ get { return sqldelete; }
+ }
+
+ #endregion
+
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmUnionSubclass.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmUnionSubclass.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmUnionSubclass.cs 2009-11-29 00:00:57 UTC (rev 4869)
@@ -0,0 +1,108 @@
+namespace NHibernate.Cfg.MappingSchema
+{
+ public partial class HbmUnionSubclass : AbstractDecoratable, IEntityMapping
+ {
+ #region Overrides of AbstractDecoratable
+
+ protected override HbmMeta[] Metadatas
+ {
+ get { return meta ?? new HbmMeta[0]; }
+ }
+
+ #endregion
+
+ #region Implementation of IEntityMapping
+
+ public string EntityName
+ {
+ get { return entityname; }
+ }
+
+ public string Name
+ {
+ get { return name; }
+ }
+
+ public string Node
+ {
+ get { return node; }
+ }
+
+ public string Proxy
+ {
+ get { return proxy; }
+ }
+
+ public bool? UseLazy
+ {
+ get { return lazySpecified ? lazy : (bool?)null; }
+ }
+
+ public HbmTuplizer[] Tuplizers
+ {
+ get { return tuplizer ?? new HbmTuplizer[0]; }
+ }
+
+ public bool DynamicUpdate
+ {
+ get { return dynamicupdate; }
+ }
+
+ public bool DynamicInsert
+ {
+ get { return dynamicinsert; }
+ }
+
+ public int? BatchSize
+ {
+ get { return !string.IsNullOrEmpty(batchsize) ? int.Parse(batchsize) : (int?)null; }
+ }
+
+ public bool SelectBeforeUpdate
+ {
+ get { return selectbeforeupdate; }
+ }
+
+ public string Persister
+ {
+ get { return persister; }
+ }
+
+ public bool? IsAbstract
+ {
+ get { return abstractSpecified ? @abstract : (bool?)null; }
+ }
+
+ public HbmSynchronize[] Synchronize
+ {
+ get { return synchronize ?? new HbmSynchronize[0]; }
+ }
+
+ #endregion
+
+ #region Implementation of IEntitySqlsMapping
+
+ public HbmLoader SqlLoader
+ {
+ get { return loader; }
+ }
+
+ public HbmCustomSQL SqlInsert
+ {
+ get { return sqlinsert; }
+ }
+
+ public HbmCustomSQL SqlUpdate
+ {
+ get { return sqlupdate; }
+ }
+
+ public HbmCustomSQL SqlDelete
+ {
+ get { return sqldelete; }
+ }
+
+ #endregion
+
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/IEntityDiscriminableMapping.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/IEntityDiscriminableMapping.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/IEntityDiscriminableMapping.cs 2009-11-29 00:00:57 UTC (rev 4869)
@@ -0,0 +1,7 @@
+namespace NHibernate.Cfg.MappingSchema
+{
+ public interface IEntityDiscriminableMapping
+ {
+ string DiscriminatorValue { get; }
+ }
+}
\ No newline at end of file
Copied: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/IEntityMapping.cs (from rev 4867, trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/IEntityMetadata.cs)
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/IEntityMapping.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/IEntityMapping.cs 2009-11-29 00:00:57 UTC (rev 4869)
@@ -0,0 +1,19 @@
+namespace NHibernate.Cfg.MappingSchema
+{
+ public interface IEntityMapping : IDecoratable, IEntitySqlsMapping
+ {
+ string EntityName { get; }
+ string Name { get; }
+ string Node { get; }
+ string Proxy { get; }
+ bool? UseLazy { get; }
+ HbmTuplizer[] Tuplizers { get; }
+ bool DynamicUpdate { get; }
+ bool DynamicInsert { get; }
+ int? BatchSize { get; }
+ bool SelectBeforeUpdate { get; }
+ string Persister { get; }
+ bool? IsAbstract { get; }
+ HbmSynchronize[] Synchronize { get; }
+ }
+}
\ No newline at end of file
Deleted: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/IEntityMetadata.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/IEntityMetadata.cs 2009-11-28 21:09:24 UTC (rev 4868)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/IEntityMetadata.cs 2009-11-29 00:00:57 UTC (rev 4869)
@@ -1,7 +0,0 @@
-namespace NHibernate.Cfg.MappingSchema
-{
- public interface IEntityMetadata
- {
-
- }
-}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/IEntitySqlsMapping.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/IEntitySqlsMapping.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/IEntitySqlsMapping.cs 2009-11-29 00:00:57 UTC (rev 4869)
@@ -0,0 +1,10 @@
+namespace NHibernate.Cfg.MappingSchema
+{
+ public interface IEntitySqlsMapping
+ {
+ HbmLoader SqlLoader { get; }
+ HbmCustomSQL SqlInsert { get; }
+ HbmCustomSQL SqlUpdate { get; }
+ HbmCustomSQL SqlDelete { get; }
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs 2009-11-28 21:09:24 UTC (rev 4868)
+++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs 2009-11-29 00:00:57 UTC (rev 4869)
@@ -1,6 +1,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
+using System.Linq;
using System.Text;
using System.Xml;
using NHibernate.Cfg.MappingSchema;
@@ -96,13 +97,13 @@
model.AddJoin(join);
}
else if ("subclass".Equals(name))
- new SubclassBinder(this).HandleSubclass(model, subnode, inheritedMetas);
+ new SubclassBinder(this).HandleSubclass(model, subnode, Deserialize<HbmSubclass>(subnode) , inheritedMetas);
else if ("joined-subclass".Equals(name))
- new JoinedSubclassBinder(this).HandleJoinedSubclass(model, subnode, inheritedMetas);
+ new JoinedSubclassBinder(this).HandleJoinedSubclass(model, subnode, Deserialize<HbmJoinedSubclass>(subnode), inheritedMetas);
else if ("union-subclass".Equals(name))
- new UnionSubclassBinder(this).HandleUnionSubclass(model, subnode, inheritedMetas);
+ new UnionSubclassBinder(this).HandleUnionSubclass(model, subnode, Deserialize<HbmUnionSubclass>(subnode), inheritedMetas);
else if ("filter".Equals(name))
ParseFilter(subnode, model);
@@ -137,18 +138,15 @@
}
}
- protected void BindClass(XmlNode node, IDecoratable classMapping, PersistentClass model, IDictionary<string, MetaAttribute> inheritedMetas)
+ protected void BindClass(IEntityMapping classMapping, PersistentClass model, IDictionary<string, MetaAttribute> inheritedMetas)
{
- // transfer an explicitly defined entity name
// handle the lazy attribute
- XmlAttribute lazyNode = node.Attributes["lazy"];
- bool lazy = lazyNode == null ? mappings.DefaultLazy : "true".Equals(lazyNode.Value);
// go ahead and set the lazy here, since pojo.proxy can override it.
- model.IsLazy = lazy;
+ model.IsLazy = classMapping.UseLazy.HasValue ? classMapping.UseLazy.Value : mappings.DefaultLazy;
- string entityName = (node.Attributes["entity-name"] != null ? node.Attributes["entity-name"].Value : null)
- ??
- ClassForNameChecked(node.Attributes["name"].Value, mappings, "persistent class {0} not found").
+ // transfer an explicitly defined entity name
+ string entityName = classMapping.EntityName ??
+ ClassForNameChecked(classMapping.Name, mappings, "persistent class {0} not found").
FullName;
if (entityName == null)
{
@@ -156,26 +154,24 @@
}
model.EntityName = entityName;
- BindPocoRepresentation(node, model);
- BindXmlRepresentation(node, model);
- BindMapRepresentation(node, model);
+ BindPocoRepresentation(classMapping, model);
+ BindXmlRepresentation(classMapping, model);
+ BindMapRepresentation(classMapping, model);
- BindPersistentClassCommonValues(node, classMapping, model, inheritedMetas);
+ BindPersistentClassCommonValues(classMapping, model, inheritedMetas);
}
- private void BindPersistentClassCommonValues(XmlNode node, IDecoratable classMapping, PersistentClass model, IDictionary<string, MetaAttribute> inheritedMetas)
+ private void BindPersistentClassCommonValues(IEntityMapping classMapping, PersistentClass model, IDictionary<string, MetaAttribute> inheritedMetas)
{
// DISCRIMINATOR
- XmlAttribute discriminatorNode = node.Attributes["discriminator-value"];
- model.DiscriminatorValue = (discriminatorNode == null) ? model.EntityName : discriminatorNode.Value;
+ var discriminable = classMapping as IEntityDiscriminableMapping;
+ model.DiscriminatorValue = (discriminable == null || string.IsNullOrEmpty(discriminable.DiscriminatorValue)) ? model.EntityName : discriminable.DiscriminatorValue;
// DYNAMIC UPDATE
- XmlAttribute dynamicNode = node.Attributes["dynamic-update"];
- model.DynamicUpdate = (dynamicNode == null) ? false : "true".Equals(dynamicNode.Value);
+ model.DynamicUpdate = classMapping.DynamicUpdate;
// DYNAMIC INSERT
- XmlAttribute insertNode = node.Attributes["dynamic-insert"];
- model.DynamicInsert = (insertNode == null) ? false : "true".Equals(insertNode.Value);
+ model.DynamicInsert = classMapping.DynamicInsert;
// IMPORT
// For entities, the EntityName is the key to find a persister
@@ -187,102 +183,81 @@
mappings.AddImport(qualifiedName, StringHelper.Unqualify(model.EntityName));
// BATCH SIZE
- XmlAttribute batchNode = node.Attributes["batch-size"];
- if (batchNode != null)
- model.BatchSize = int.Parse(batchNode.Value);
+ if (classMapping.BatchSize.HasValue)
+ model.BatchSize = classMapping.BatchSize.Value;
// SELECT BEFORE UPDATE
- XmlAttribute sbuNode = node.Attributes["select-before-update"];
- if (sbuNode != null)
- model.SelectBeforeUpdate = "true".Equals(sbuNode.Value);
+ model.SelectBeforeUpdate = classMapping.SelectBeforeUpdate;;
- // OPTIMISTIC LOCK MODE
- XmlAttribute olNode = node.Attributes["optimistic-lock"];
- model.OptimisticLockMode = GetOptimisticLockMode(olNode);
+ // OPTIMISTIC LOCK MODE (hack)
+ var hbmClass = classMapping as HbmClass;
+ if(hbmClass != null)
+ {
+ model.OptimisticLockMode = hbmClass.optimisticlock.ToOptimisticLock();
+ }
// META ATTRIBUTES
- model.MetaAttributes = classMapping != null
- ? GetMetas(classMapping, inheritedMetas)
- : GetMetas(node.SelectNodes(HbmConstants.nsMeta, namespaceManager), inheritedMetas);
+ model.MetaAttributes = GetMetas(classMapping, inheritedMetas);
// PERSISTER
- XmlAttribute persisterNode = node.Attributes["persister"];
- if (persisterNode == null)
- {
- //persister = typeof( EntityPersister );
- }
- else
- model.EntityPersisterClass = ClassForNameChecked(persisterNode.Value, mappings,
+ if(!string.IsNullOrEmpty(classMapping.Persister))
+ model.EntityPersisterClass = ClassForNameChecked(classMapping.Persister, mappings,
"could not instantiate persister class: {0}");
// CUSTOM SQL
- HandleCustomSQL(node, model);
+ HandleCustomSQL(classMapping, model);
- foreach (XmlNode syncNode in node.SelectNodes(HbmConstants.nsSynchronize, namespaceManager))
- model.AddSynchronizedTable(XmlHelper.GetAttributeValue(syncNode, "table"));
-
- bool? isAbstract = null;
- XmlAttribute abstractNode = node.Attributes["abstract"];
- if (abstractNode != null)
+ foreach (var synchronize in classMapping.Synchronize)
{
- if ("true".Equals(abstractNode.Value) || "1".Equals(abstractNode.Value))
- isAbstract = true;
- else if ("false".Equals(abstractNode.Value) || "0".Equals(abstractNode.Value))
- isAbstract = false;
+ model.AddSynchronizedTable(synchronize.table);
}
- model.IsAbstract = isAbstract;
+
+ model.IsAbstract = classMapping.IsAbstract;
}
- private void BindMapRepresentation(XmlNode node, PersistentClass entity)
+ private void BindMapRepresentation(IEntityMapping classMapping, PersistentClass entity)
{
- XmlNode tuplizer = LocateTuplizerDefinition(node, EntityMode.Map);
+ HbmTuplizer tuplizer = classMapping.Tuplizers.FirstOrDefault(tp => tp.entitymode == HbmTuplizerEntitymode.DynamicMap);
if (tuplizer != null)
{
- string tupClassName = FullQualifiedClassName(tuplizer.Attributes["class"].Value, mappings);
+ string tupClassName = FullQualifiedClassName(tuplizer.@class, mappings);
entity.AddTuplizer(EntityMode.Map, tupClassName);
}
}
- private void BindXmlRepresentation(XmlNode node, PersistentClass entity)
+ private void BindXmlRepresentation(IEntityMapping classMapping, PersistentClass entity)
{
- string nodeName = null;
- XmlAttribute nodeAtt = node.Attributes["node"];
- if(nodeAtt != null)
- nodeName = nodeAtt.Value;
- if (nodeName == null)
- nodeName = StringHelper.Unqualify(entity.EntityName);
- entity.NodeName = nodeName;
+ entity.NodeName = string.IsNullOrEmpty(classMapping.Node) ? StringHelper.Unqualify(entity.EntityName): classMapping.Node;
- XmlNode tuplizer = LocateTuplizerDefinition(node, EntityMode.Xml);
+ HbmTuplizer tuplizer = classMapping.Tuplizers.FirstOrDefault(tp => tp.entitymode == HbmTuplizerEntitymode.Xml);
if (tuplizer != null)
{
- string tupClassName = FullQualifiedClassName(tuplizer.Attributes["class"].Value, mappings);
+ string tupClassName = FullQualifiedClassName(tuplizer.@class, mappings);
entity.AddTuplizer(EntityMode.Xml, tupClassName);
}
}
- private void BindPocoRepresentation(XmlNode node, PersistentClass entity)
+ private void BindPocoRepresentation(IEntityMapping classMapping, PersistentClass entity)
{
- string className = node.Attributes["name"] == null
+ string className = classMapping.Name == null
? null
- : ClassForNameChecked(node.Attributes["name"].Value, mappings, "persistent class {0} not found").
+ : ClassForNameChecked(classMapping.Name, mappings, "persistent class {0} not found").
AssemblyQualifiedName;
entity.ClassName = className;
- XmlAttribute proxyNode = node.Attributes["proxy"];
- if (proxyNode != null)
+ if (!string.IsNullOrEmpty(classMapping.Proxy))
{
- entity.ProxyInterfaceName = ClassForNameChecked(proxyNode.Value, mappings, "proxy class not found: {0}").AssemblyQualifiedName;
+ entity.ProxyInterfaceName = ClassForNameChecked(classMapping.Proxy, mappings, "proxy class not found: {0}").AssemblyQualifiedName;
entity.IsLazy = true;
}
else if (entity.IsLazy)
entity.ProxyInterfaceName = className;
- XmlNode tuplizer = LocateTuplizerDefinition(node, EntityMode.Poco);
+ HbmTuplizer tuplizer = classMapping.Tuplizers.FirstOrDefault(tp=> tp.entitymode == HbmTuplizerEntitymode.Poco);
if (tuplizer != null)
{
- string tupClassName = FullQualifiedClassName(tuplizer.Attributes["class"].Value, mappings);
+ string tupClassName = FullQualifiedClassName(tuplizer.@class, mappings);
entity.AddTuplizer(EntityMode.Poco, tupClassName);
}
}
@@ -313,7 +288,8 @@
XmlAttribute actionNode = node.Attributes["schema-action"];
string action = actionNode == null ? "all" : actionNode.Value;
- Table table = mappings.AddTable(schema, catalog, GetClassTableName(persistentClass, node), null, false, action);
+ string tableName = node.Attributes["table"] != null ? node.Attributes["table"].Value : null;
+ Table table = mappings.AddTable(schema, catalog, GetClassTableName(persistentClass, tableName), null, false, action);
join.Table = table;
XmlAttribute fetchNode = node.Attributes["fetch"];
@@ -401,33 +377,31 @@
HandleCustomSQL(node, join);
}
- private void HandleCustomSQL(XmlNode node, PersistentClass model)
+ private void HandleCustomSQL(IEntitySqlsMapping sqlsMapping, PersistentClass model)
{
- XmlNode element = node.SelectSingleNode(HbmConstants.nsSqlInsert, namespaceManager);
-
- if (element != null)
+ var sqlInsert = sqlsMapping.SqlInsert;
+ if (sqlInsert != null)
{
- bool callable = IsCallable(element);
- model.SetCustomSQLInsert(element.InnerText.Trim(), callable, GetResultCheckStyle(element, callable));
+ bool callable = sqlInsert.callableSpecified && sqlInsert.callable;
+ model.SetCustomSQLInsert(sqlInsert.Text.LinesToString(), callable, GetResultCheckStyle(sqlInsert));
}
- element = node.SelectSingleNode(HbmConstants.nsSqlDelete, namespaceManager);
- if (element != null)
+ var sqlDelete = sqlsMapping.SqlDelete;
+ if (sqlDelete != null)
{
- bool callable = IsCallable(element);
- model.SetCustomSQLDelete(element.InnerText.Trim(), callable, GetResultCheckStyle(element, callable));
+ bool callable = sqlDelete.callableSpecified && sqlDelete.callable;
+ model.SetCustomSQLDelete(sqlDelete.Text.LinesToString(), callable, GetResultCheckStyle(sqlDelete));
}
- element = node.SelectSingleNode(HbmConstants.nsSqlUpdate, namespaceManager);
- if (element != null)
+ var sqlUpdate = sqlsMapping.SqlUpdate;
+ if (sqlUpdate != null)
{
- bool callable = IsCallable(element);
- model.SetCustomSQLUpdate(element.InnerText.Trim(), callable, GetResultCheckStyle(element, callable));
+ bool callable = sqlUpdate.callableSpecified && sqlUpdate.callable;
+ model.SetCustomSQLUpdate(sqlUpdate.Text.LinesToString(), callable, GetResultCheckStyle(sqlUpdate));
}
- element = node.SelectSingleNode(HbmConstants.nsLoader, namespaceManager);
- if (element != null)
- model.LoaderName = XmlHelper.GetAttributeValue(element, "query-ref");
+ if (sqlsMapping.SqlLoader != null)
+ model.LoaderName = sqlsMapping.SqlLoader.queryref;
}
private void HandleCustomSQL(XmlNode node, Join model)
@@ -494,13 +468,11 @@
return superModel;
}
- protected string GetClassTableName(PersistentClass model, XmlNode node)
+ protected string GetClassTableName(PersistentClass model, string mappedTableName)
{
- XmlAttribute tableNameNode = node.Attributes["table"];
- if (tableNameNode == null)
- return mappings.NamingStrategy.ClassToTableName(model.EntityName);
- else
- return mappings.NamingStrategy.TableName(tableNameNode.Value);
+ return string.IsNullOrEmpty(mappedTableName)
+ ? mappings.NamingStrategy.ClassToTableName(model.EntityName)
+ : mappings.NamingStrategy.TableName(mappedTableName);
}
protected void MakeIdentifier(XmlNode node, SimpleValue model)
@@ -1004,6 +976,31 @@
return ExecuteUpdateResultCheckStyle.Parse(attr.Value);
}
+ protected static ExecuteUpdateResultCheckStyle GetResultCheckStyle(HbmCustomSQL customSQL)
+ {
+ if (customSQL != null)
+ {
+ if (!customSQL.checkSpecified)
+ {
+ return ExecuteUpdateResultCheckStyle.Count;
+ }
+ else
+ {
+ switch (customSQL.check)
+ {
+ case HbmCustomSQLCheck.None:
+ return ExecuteUpdateResultCheckStyle.None;
+ break;
+ case HbmCustomSQLCheck.Rowcount:
+ return ExecuteUpdateResultCheckStyle.Count;
+ case HbmCustomSQLCheck.Param:
+ return null; // not supported
+ }
+ }
+ }
+ return null;
+ }
+
protected void ParseFilter(XmlNode filterElement, IFilterable filterable)
{
string name = GetPropertyName(filterElement);
Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/JoinedSubclassBinder.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/JoinedSubclassBinder.cs 2009-11-28 21:09:24 UTC (rev 4868)
+++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/JoinedSubclassBinder.cs 2009-11-29 00:00:57 UTC (rev 4869)
@@ -1,5 +1,5 @@
using System.Xml;
-
+using NHibernate.Cfg.MappingSchema;
using NHibernate.Mapping;
using NHibernate.Persister.Entity;
using System.Collections.Generic;
@@ -18,32 +18,32 @@
{
}
- public void Bind(XmlNode node, IDictionary<string, MetaAttribute> inheritedMetas)
+ public void Bind(XmlNode node, HbmJoinedSubclass joinedSubclassMapping, IDictionary<string, MetaAttribute> inheritedMetas)
{
PersistentClass superModel = GetSuperclass(node);
- HandleJoinedSubclass(superModel, node, inheritedMetas);
+ HandleJoinedSubclass(superModel, node, joinedSubclassMapping, inheritedMetas);
}
- public void HandleJoinedSubclass(PersistentClass model, XmlNode subnode, IDictionary<string, MetaAttribute> inheritedMetas)
+ public void HandleJoinedSubclass(Persisten...
[truncated message content] |
|
From: <fab...@us...> - 2009-11-29 12:57:02
|
Revision: 4871
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4871&view=rev
Author: fabiomaulo
Date: 2009-11-29 12:56:53 +0000 (Sun, 29 Nov 2009)
Log Message:
-----------
Binders refactoring (removed method used only in one test and removed the test itself)
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/RootClassBinder.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Removed Paths:
-------------
trunk/nhibernate/src/NHibernate.Test/CfgTest/HbmBinderFixture.cs
Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/RootClassBinder.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/RootClassBinder.cs 2009-11-29 12:48:34 UTC (rev 4870)
+++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/RootClassBinder.cs 2009-11-29 12:56:53 UTC (rev 4871)
@@ -300,17 +300,6 @@
LogMappedProperty(property);
}
- public static void MakeVersion(XmlNode node, SimpleValue model)
- {
- if (node != null && node.Attributes != null)
- {
- XmlAttribute attribute = node.Attributes["unsaved-value"];
- model.NullValue = attribute == null ? null : attribute.Value;
- }
- else
- model.NullValue = null;
- }
-
private static void BindCache(HbmCache cacheSchema, RootClass rootClass)
{
if (cacheSchema != null)
Deleted: trunk/nhibernate/src/NHibernate.Test/CfgTest/HbmBinderFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/CfgTest/HbmBinderFixture.cs 2009-11-29 12:48:34 UTC (rev 4870)
+++ trunk/nhibernate/src/NHibernate.Test/CfgTest/HbmBinderFixture.cs 2009-11-29 12:56:53 UTC (rev 4871)
@@ -1,59 +0,0 @@
-using System;
-using System.IO;
-using System.Xml;
-using NHibernate.Cfg;
-using NHibernate.Cfg.XmlHbmBinding;
-using NHibernate.Mapping;
-using NUnit.Framework;
-
-namespace NHibernate.Test.CfgTest
-{
- [TestFixture]
- public class HbmBinderFixture
- {
- private XmlDocument LoadAndValidate(string xml, string name)
- {
- using (StringReader stringReader = new StringReader(xml))
- {
- XmlTextReader xmlReader = new XmlTextReader(stringReader);
- Configuration cfg = new Configuration();
- return cfg.LoadMappingDocument(xmlReader, name).Document;
- }
- }
-
- private string GetXmlForTesting(string versionTag)
- {
- string XML_TEMPLATE =
- @"<?xml version='1.0' ?>
-<hibernate-mapping xmlns='urn:nhibernate-mapping-2.2'>
- <class name='class'>
- <id column='id'>
- <generator class='generator' />
- </id>
- <{0} name='{0}' />
- </class>
-</hibernate-mapping>";
-
- return String.Format(XML_TEMPLATE, versionTag);
- }
-
- private void CheckDefaultUnsavedValue(string versionTag)
- {
- string XML = GetXmlForTesting(versionTag);
- XmlDocument document = LoadAndValidate(XML, versionTag);
- XmlNode node = document.GetElementsByTagName(versionTag)[0];
- SimpleValue model = new SimpleValue();
- RootClassBinder.MakeVersion(node, model);
- Assert.IsNull(model.NullValue,
- "default unsaved-value for tag {0} should be null, but is '{1}'",
- versionTag, model.NullValue);
- }
-
- [Test]
- public void DefaultUnsavedValueIsUndefined()
- {
- CheckDefaultUnsavedValue("version");
- CheckDefaultUnsavedValue("timestamp");
- }
- }
-}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-11-29 12:48:34 UTC (rev 4870)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-11-29 12:56:53 UTC (rev 4871)
@@ -113,7 +113,6 @@
<Compile Include="CfgTest\ConfigurationSerializationTests.cs" />
<Compile Include="CfgTest\DefaultNsAssmFixture.cs" />
<Compile Include="CfgTest\EntityCacheUsageParserFixture.cs" />
- <Compile Include="CfgTest\HbmBinderFixture.cs" />
<Compile Include="CfgTest\HbmOrderingFixture.cs" />
<Compile Include="CfgTest\LocatedInTestAssembly.cs" />
<Compile Include="CfgTest\Loquacious\ConfigurationFixture.cs" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2009-11-29 16:09:03
|
Revision: 4873
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4873&view=rev
Author: fabiomaulo
Date: 2009-11-29 16:08:44 +0000 (Sun, 29 Nov 2009)
Log Message:
-----------
Preparing other binders refactoring
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmClass.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmJoinedSubclass.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmSubclass.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmUnionSubclass.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/IEntityMapping.cs
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/Binder.cs
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/CollectionBinder.cs
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/RootClassBinder.cs
trunk/nhibernate/src/NHibernate/NHibernate.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmAny.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmArray.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmBag.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmComponent.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmIdbag.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmList.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmManyToOne.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmMap.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmNaturalId.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmOneToOne.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmPrimitiveArray.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmProperty.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmSet.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/ICollectionPropertyMapping.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/IEntityPropertyMapping.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/IPropertiesContainerMapping.cs
Added: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmAny.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmAny.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmAny.cs 2009-11-29 16:08:44 UTC (rev 4873)
@@ -0,0 +1,14 @@
+namespace NHibernate.Cfg.MappingSchema
+{
+ public partial class HbmAny : IEntityPropertyMapping
+ {
+ #region Implementation of IEntityPropertyMapping
+
+ public string Name
+ {
+ get { return name; }
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmArray.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmArray.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmArray.cs 2009-11-29 16:08:44 UTC (rev 4873)
@@ -0,0 +1,14 @@
+namespace NHibernate.Cfg.MappingSchema
+{
+ public partial class HbmArray : ICollectionPropertyMapping
+ {
+ #region Implementation of IEntityPropertyMapping
+
+ public string Name
+ {
+ get { return name; }
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmBag.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmBag.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmBag.cs 2009-11-29 16:08:44 UTC (rev 4873)
@@ -0,0 +1,14 @@
+namespace NHibernate.Cfg.MappingSchema
+{
+ public partial class HbmBag : ICollectionPropertyMapping
+ {
+ #region Implementation of IEntityPropertyMapping
+
+ public string Name
+ {
+ get { return name; }
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmClass.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmClass.cs 2009-11-29 13:10:49 UTC (rev 4872)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmClass.cs 2009-11-29 16:08:44 UTC (rev 4873)
@@ -1,3 +1,7 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
namespace NHibernate.Cfg.MappingSchema
{
partial class HbmClass : AbstractDecoratable, IEntityMapping, IEntityDiscriminableMapping
@@ -128,5 +132,14 @@
}
#endregion
+
+ #region Implementation of IPropertiesContainerMapping
+
+ public IEnumerable<IEntityPropertyMapping> Properties
+ {
+ get { return Items.Cast<IEntityPropertyMapping>(); }
+ }
+
+ #endregion
}
}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmComponent.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmComponent.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmComponent.cs 2009-11-29 16:08:44 UTC (rev 4873)
@@ -0,0 +1,27 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace NHibernate.Cfg.MappingSchema
+{
+ public partial class HbmComponent : IEntityPropertyMapping, IPropertiesContainerMapping
+ {
+ #region Implementation of IEntityPropertyMapping
+
+ public string Name
+ {
+ get { return name; }
+ }
+
+ #endregion
+
+ #region Implementation of IPropertiesContainerMapping
+
+ public IEnumerable<IEntityPropertyMapping> Properties
+ {
+ get { return Items.Cast<IEntityPropertyMapping>(); }
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmIdbag.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmIdbag.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmIdbag.cs 2009-11-29 16:08:44 UTC (rev 4873)
@@ -0,0 +1,14 @@
+namespace NHibernate.Cfg.MappingSchema
+{
+ public partial class HbmIdbag : ICollectionPropertyMapping
+ {
+ #region Implementation of IEntityPropertyMapping
+
+ public string Name
+ {
+ get { return name; }
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmJoinedSubclass.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmJoinedSubclass.cs 2009-11-29 13:10:49 UTC (rev 4872)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmJoinedSubclass.cs 2009-11-29 16:08:44 UTC (rev 4873)
@@ -1,3 +1,6 @@
+using System.Collections.Generic;
+using System.Linq;
+
namespace NHibernate.Cfg.MappingSchema
{
public partial class HbmJoinedSubclass : AbstractDecoratable, IEntityMapping
@@ -102,5 +105,14 @@
}
#endregion
+
+ #region Implementation of IPropertiesContainerMapping
+
+ public IEnumerable<IEntityPropertyMapping> Properties
+ {
+ get { return Items.Cast<IEntityPropertyMapping>(); }
+ }
+
+ #endregion
}
}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmList.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmList.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmList.cs 2009-11-29 16:08:44 UTC (rev 4873)
@@ -0,0 +1,14 @@
+namespace NHibernate.Cfg.MappingSchema
+{
+ public partial class HbmList : ICollectionPropertyMapping
+ {
+ #region Implementation of IEntityPropertyMapping
+
+ public string Name
+ {
+ get { return name; }
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmManyToOne.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmManyToOne.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmManyToOne.cs 2009-11-29 16:08:44 UTC (rev 4873)
@@ -0,0 +1,14 @@
+namespace NHibernate.Cfg.MappingSchema
+{
+ public partial class HbmManyToOne : IEntityPropertyMapping
+ {
+ #region Implementation of IEntityPropertyMapping
+
+ public string Name
+ {
+ get { return name; }
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmMap.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmMap.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmMap.cs 2009-11-29 16:08:44 UTC (rev 4873)
@@ -0,0 +1,14 @@
+namespace NHibernate.Cfg.MappingSchema
+{
+ public partial class HbmMap : ICollectionPropertyMapping
+ {
+ #region Implementation of IEntityPropertyMapping
+
+ public string Name
+ {
+ get { return name; }
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmNaturalId.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmNaturalId.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmNaturalId.cs 2009-11-29 16:08:44 UTC (rev 4873)
@@ -0,0 +1,18 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace NHibernate.Cfg.MappingSchema
+{
+ public partial class HbmNaturalId: IPropertiesContainerMapping
+ {
+ #region Implementation of IPropertiesContainerMapping
+
+ public IEnumerable<IEntityPropertyMapping> Properties
+ {
+ get { return Items.Cast<IEntityPropertyMapping>(); }
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmOneToOne.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmOneToOne.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmOneToOne.cs 2009-11-29 16:08:44 UTC (rev 4873)
@@ -0,0 +1,14 @@
+namespace NHibernate.Cfg.MappingSchema
+{
+ public partial class HbmOneToOne : IEntityPropertyMapping
+ {
+ #region Implementation of IEntityPropertyMapping
+
+ public string Name
+ {
+ get { return name; }
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmPrimitiveArray.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmPrimitiveArray.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmPrimitiveArray.cs 2009-11-29 16:08:44 UTC (rev 4873)
@@ -0,0 +1,15 @@
+namespace NHibernate.Cfg.MappingSchema
+{
+ public partial class HbmPrimitiveArray : ICollectionPropertyMapping
+ {
+ #region Implementation of IEntityPropertyMapping
+
+ public string Name
+ {
+ get { return name; }
+ }
+
+ #endregion
+
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmProperty.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmProperty.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmProperty.cs 2009-11-29 16:08:44 UTC (rev 4873)
@@ -0,0 +1,14 @@
+namespace NHibernate.Cfg.MappingSchema
+{
+ public partial class HbmProperty : IEntityPropertyMapping
+ {
+ #region Implementation of IEntityPropertyMapping
+
+ public string Name
+ {
+ get { return name; }
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmSet.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmSet.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmSet.cs 2009-11-29 16:08:44 UTC (rev 4873)
@@ -0,0 +1,14 @@
+namespace NHibernate.Cfg.MappingSchema
+{
+ public partial class HbmSet : ICollectionPropertyMapping
+ {
+ #region Implementation of IEntityPropertyMapping
+
+ public string Name
+ {
+ get { return name; }
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmSubclass.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmSubclass.cs 2009-11-29 13:10:49 UTC (rev 4872)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmSubclass.cs 2009-11-29 16:08:44 UTC (rev 4873)
@@ -1,3 +1,6 @@
+using System.Collections.Generic;
+using System.Linq;
+
namespace NHibernate.Cfg.MappingSchema
{
public partial class HbmSubclass : AbstractDecoratable, IEntityMapping, IEntityDiscriminableMapping
@@ -113,5 +116,13 @@
#endregion
+ #region Implementation of IPropertiesContainerMapping
+
+ public IEnumerable<IEntityPropertyMapping> Properties
+ {
+ get { return Items.Cast<IEntityPropertyMapping>(); }
+ }
+
+ #endregion
}
}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmUnionSubclass.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmUnionSubclass.cs 2009-11-29 13:10:49 UTC (rev 4872)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmUnionSubclass.cs 2009-11-29 16:08:44 UTC (rev 4873)
@@ -1,3 +1,6 @@
+using System.Collections.Generic;
+using System.Linq;
+
namespace NHibernate.Cfg.MappingSchema
{
public partial class HbmUnionSubclass : AbstractDecoratable, IEntityMapping
@@ -104,5 +107,13 @@
#endregion
+ #region Implementation of IPropertiesContainerMapping
+
+ public IEnumerable<IEntityPropertyMapping> Properties
+ {
+ get { return Items.Cast<IEntityPropertyMapping>(); }
+ }
+
+ #endregion
}
}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/ICollectionPropertyMapping.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/ICollectionPropertyMapping.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/ICollectionPropertyMapping.cs 2009-11-29 16:08:44 UTC (rev 4873)
@@ -0,0 +1,7 @@
+namespace NHibernate.Cfg.MappingSchema
+{
+ public interface ICollectionPropertyMapping: IEntityPropertyMapping
+ {
+
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/IEntityMapping.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/IEntityMapping.cs 2009-11-29 13:10:49 UTC (rev 4872)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/IEntityMapping.cs 2009-11-29 16:08:44 UTC (rev 4873)
@@ -1,6 +1,6 @@
namespace NHibernate.Cfg.MappingSchema
{
- public interface IEntityMapping : IDecoratable, IEntitySqlsMapping
+ public interface IEntityMapping : IDecoratable, IEntitySqlsMapping, IPropertiesContainerMapping
{
string EntityName { get; }
string Name { get; }
Added: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/IEntityPropertyMapping.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/IEntityPropertyMapping.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/IEntityPropertyMapping.cs 2009-11-29 16:08:44 UTC (rev 4873)
@@ -0,0 +1,7 @@
+namespace NHibernate.Cfg.MappingSchema
+{
+ public interface IEntityPropertyMapping
+ {
+ string Name { get; }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/IPropertiesContainerMapping.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/IPropertiesContainerMapping.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/IPropertiesContainerMapping.cs 2009-11-29 16:08:44 UTC (rev 4873)
@@ -0,0 +1,8 @@
+using System.Collections.Generic;
+namespace NHibernate.Cfg.MappingSchema
+{
+ public interface IPropertiesContainerMapping
+ {
+ IEnumerable<IEntityPropertyMapping> Properties { get; }
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/Binder.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/Binder.cs 2009-11-29 13:10:49 UTC (rev 4872)
+++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/Binder.cs 2009-11-29 16:08:44 UTC (rev 4873)
@@ -148,7 +148,14 @@
protected static XmlNode Serialize<T>(T hbmElement)
{
// TODO : this method is only for TEMPORAL usage; should be removed after refactorize all binders
- var serializer = new XmlSerializer(typeof (T));
+ var xmlTypeMapping = typeof (T);
+ return Serialize(xmlTypeMapping, hbmElement);
+ }
+
+ protected static XmlNode Serialize(System.Type xmlTypeMapping, object hbmElement)
+ {
+ // TODO : this method is only for TEMPORAL usage; should be removed after refactorize all binders
+ var serializer = new XmlSerializer(xmlTypeMapping);
using (var memStream = new MemoryStream(2000))
using (var xmlWriter = XmlWriter.Create(memStream))
{
Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/CollectionBinder.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/CollectionBinder.cs 2009-11-29 13:10:49 UTC (rev 4872)
+++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/CollectionBinder.cs 2009-11-29 16:08:44 UTC (rev 4873)
@@ -7,14 +7,30 @@
using NHibernate.Util;
using Array = NHibernate.Mapping.Array;
+using NHibernate.Cfg.MappingSchema;
namespace NHibernate.Cfg.XmlHbmBinding
{
public class CollectionBinder : ClassBinder
{
+ private static readonly HashSet<System.Type> SupportedCollections = new HashSet<System.Type>
+ {
+ typeof (HbmMap),
+ typeof (HbmBag),
+ typeof (HbmIdbag),
+ typeof (HbmSet),
+ typeof (HbmList),
+ typeof (HbmArray),
+ typeof (HbmPrimitiveArray)
+ };
private readonly IDictionary<string, CreateCollectionCommand> createCollectionCommands =
new Dictionary<string, CreateCollectionCommand>();
+ public static bool IsSupported(System.Type type)
+ {
+ return SupportedCollections.Contains(type);
+ }
+
public CollectionBinder(ClassBinder parent)
: base(parent)
{
@@ -37,6 +53,49 @@
return createCollectionCommands.ContainsKey(xmlTagName);
}
+ public Mapping.Collection Create(ICollectionPropertyMapping collectionMapping, string className,
+ string path, PersistentClass owner, System.Type containingType, IDictionary<string, MetaAttribute> inheritedMetas)
+ {
+ var collectionType = collectionMapping.GetType();
+ if (collectionType == typeof (HbmBag))
+ {
+ return createCollectionCommands["bag"](Serialize(typeof (HbmBag), collectionMapping), className, path, owner,
+ containingType, inheritedMetas);
+ }
+ else if (collectionType == typeof (HbmSet))
+ {
+ return createCollectionCommands["set"](Serialize(typeof(HbmSet), collectionMapping), className, path, owner,
+ containingType, inheritedMetas);
+ }
+ else if (collectionType == typeof (HbmList))
+ {
+ return createCollectionCommands["list"](Serialize(typeof(HbmList), collectionMapping), className, path, owner,
+ containingType, inheritedMetas);
+ }
+ else if (collectionType == typeof (HbmMap))
+ {
+ return createCollectionCommands["map"](Serialize(typeof(HbmMap), collectionMapping), className, path, owner,
+ containingType, inheritedMetas);
+ }
+ else if (collectionType == typeof (HbmIdbag))
+ {
+ return createCollectionCommands["idbag"](Serialize(typeof(HbmIdbag), collectionMapping), className, path, owner,
+ containingType, inheritedMetas);
+ }
+ else if (collectionType == typeof (HbmArray))
+ {
+ return createCollectionCommands["array"](Serialize(typeof(HbmArray), collectionMapping), className, path, owner,
+ containingType, inheritedMetas);
+ }
+ else if (collectionType == typeof (HbmPrimitiveArray))
+ {
+ return createCollectionCommands["primitive-array"](Serialize(typeof(HbmPrimitiveArray), collectionMapping), className, path, owner,
+ containingType, inheritedMetas);
+ }
+ throw new MappingException("Not supported collection mapping element:" + collectionType);
+ }
+
+
public Mapping.Collection Create(string xmlTagName, XmlNode node, string className,
string path, PersistentClass owner, System.Type containingType, IDictionary<string, MetaAttribute> inheritedMetas)
{
Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/RootClassBinder.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/RootClassBinder.cs 2009-11-29 13:10:49 UTC (rev 4872)
+++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/RootClassBinder.cs 2009-11-29 16:08:44 UTC (rev 4873)
@@ -55,7 +55,6 @@
BindVersion(classSchema.Version, rootClass, table, inheritedMetas);
rootClass.CreatePrimaryKey(dialect);
-
PropertiesFromXML(node, rootClass, inheritedMetas);
mappings.AddClass(rootClass);
}
Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-11-29 13:10:49 UTC (rev 4872)
+++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-11-29 16:08:44 UTC (rev 4873)
@@ -494,14 +494,30 @@
<Compile Include="Cfg\Loquacious\ITypeDefConfiguration.cs" />
<Compile Include="Cfg\Loquacious\MappingsConfiguration.cs" />
<Compile Include="Cfg\Loquacious\ProxyConfiguration.cs" />
+ <Compile Include="Cfg\MappingSchema\HbmAny.cs" />
+ <Compile Include="Cfg\MappingSchema\HbmArray.cs" />
+ <Compile Include="Cfg\MappingSchema\HbmBag.cs" />
+ <Compile Include="Cfg\MappingSchema\HbmComponent.cs" />
<Compile Include="Cfg\MappingSchema\HbmDefinition.cs" />
<Compile Include="Cfg\MappingSchema\HbmExtensions.cs" />
+ <Compile Include="Cfg\MappingSchema\HbmIdbag.cs" />
<Compile Include="Cfg\MappingSchema\HbmJoinedSubclass.cs" />
+ <Compile Include="Cfg\MappingSchema\HbmList.cs" />
+ <Compile Include="Cfg\MappingSchema\HbmManyToOne.cs" />
+ <Compile Include="Cfg\MappingSchema\HbmMap.cs" />
+ <Compile Include="Cfg\MappingSchema\HbmNaturalId.cs" />
+ <Compile Include="Cfg\MappingSchema\HbmOneToOne.cs" />
+ <Compile Include="Cfg\MappingSchema\HbmPrimitiveArray.cs" />
+ <Compile Include="Cfg\MappingSchema\HbmProperty.cs" />
+ <Compile Include="Cfg\MappingSchema\HbmSet.cs" />
<Compile Include="Cfg\MappingSchema\HbmSubclass.cs" />
<Compile Include="Cfg\MappingSchema\HbmUnionSubclass.cs" />
+ <Compile Include="Cfg\MappingSchema\ICollectionPropertyMapping.cs" />
<Compile Include="Cfg\MappingSchema\IEntityDiscriminableMapping.cs" />
<Compile Include="Cfg\MappingSchema\IEntityMapping.cs" />
+ <Compile Include="Cfg\MappingSchema\IEntityPropertyMapping.cs" />
<Compile Include="Cfg\MappingSchema\IEntitySqlsMapping.cs" />
+ <Compile Include="Cfg\MappingSchema\IPropertiesContainerMapping.cs" />
<Compile Include="Cfg\SchemaAutoAction.cs" />
<Compile Include="Cfg\SessionFactoryConfigurationBase.cs" />
<Compile Include="Cfg\ISessionFactoryConfiguration.cs" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ric...@us...> - 2009-11-29 20:48:06
|
Revision: 4874
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4874&view=rev
Author: ricbrown
Date: 2009-11-29 20:47:58 +0000 (Sun, 29 Nov 2009)
Log Message:
-----------
Fix NH-2027 (Call Oracle procedures inside packages; using dot notation)
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Engine/Query/CallableParser.cs
trunk/nhibernate/src/NHibernate.Test/EngineTest/CallableParserFixture.cs
Modified: trunk/nhibernate/src/NHibernate/Engine/Query/CallableParser.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Engine/Query/CallableParser.cs 2009-11-29 16:08:44 UTC (rev 4873)
+++ trunk/nhibernate/src/NHibernate/Engine/Query/CallableParser.cs 2009-11-29 20:47:58 UTC (rev 4874)
@@ -16,7 +16,7 @@
public string FunctionName;
}
- private static readonly Regex functionNameFinder = new Regex(@"\{[\S\s]*call[\s]+([\w]+)[^\w]");
+ private static readonly Regex functionNameFinder = new Regex(@"\{[\S\s]*call[\s]+([\w\.]+)[^\w]");
private static readonly int NewLineLength = Environment.NewLine.Length;
public static Detail Parse(string sqlString)
Modified: trunk/nhibernate/src/NHibernate.Test/EngineTest/CallableParserFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/EngineTest/CallableParserFixture.cs 2009-11-29 16:08:44 UTC (rev 4873)
+++ trunk/nhibernate/src/NHibernate.Test/EngineTest/CallableParserFixture.cs 2009-11-29 20:47:58 UTC (rev 4874)
@@ -45,6 +45,15 @@
}
[Test]
+ public void CanFindCallablePackageFunctionName()
+ {
+ string query = @"{ call myPackage.No2_Function(:name) }";
+
+ CallableParser.Detail detail = CallableParser.Parse(query);
+ Assert.That(detail.FunctionName, Is.EqualTo("myPackage.No2_Function"));
+ }
+
+ [Test]
public void CanDetermineHasReturn()
{
string query = @"{ ? = call myFunction(:name) }";
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2009-11-30 03:21:11
|
Revision: 4875
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4875&view=rev
Author: fabiomaulo
Date: 2009-11-30 03:21:02 +0000 (Mon, 30 Nov 2009)
Log Message:
-----------
binders refactoring (pushing down the XML parsing)
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmAny.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmArray.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmBag.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmClass.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmComponent.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmExtensions.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmIdbag.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmJoinedSubclass.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmList.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmManyToOne.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmMap.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmNaturalId.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmOneToOne.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmPrimitiveArray.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmProperty.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmSet.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmSubclass.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmUnionSubclass.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/ICollectionPropertyMapping.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/IEntityPropertyMapping.cs
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/Binder.cs
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassIdBinder.cs
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/CollectionBinder.cs
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/JoinedSubclassBinder.cs
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/MappingRootBinder.cs
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/NamedQueryBinder.cs
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/NamedSQLQueryBinder.cs
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ResultSetMappingBinder.cs
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/RootClassBinder.cs
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/SubclassBinder.cs
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/UnionSubclassBinder.cs
trunk/nhibernate/src/NHibernate/NHibernate.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmDynamicComponent.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/IReferencePropertyMapping.cs
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/FiltersBinder.cs
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/PropertiesBinder.cs
Modified: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmAny.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmAny.cs 2009-11-29 20:47:58 UTC (rev 4874)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmAny.cs 2009-11-30 03:21:02 UTC (rev 4875)
@@ -1,6 +1,8 @@
+using System;
+
namespace NHibernate.Cfg.MappingSchema
{
- public partial class HbmAny : IEntityPropertyMapping
+ public partial class HbmAny : AbstractDecoratable, IEntityPropertyMapping
{
#region Implementation of IEntityPropertyMapping
@@ -9,6 +11,25 @@
get { return name; }
}
+ public string Access
+ {
+ get { return access; }
+ }
+
+ public bool OptimisticKock
+ {
+ get { return optimisticlock; }
+ }
+
#endregion
+
+ #region Overrides of AbstractDecoratable
+
+ protected override HbmMeta[] Metadatas
+ {
+ get { return meta ?? new HbmMeta[0]; }
+ }
+
+ #endregion
}
}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmArray.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmArray.cs 2009-11-29 20:47:58 UTC (rev 4874)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmArray.cs 2009-11-30 03:21:02 UTC (rev 4875)
@@ -1,6 +1,8 @@
+using System;
+
namespace NHibernate.Cfg.MappingSchema
{
- public partial class HbmArray : ICollectionPropertyMapping
+ public partial class HbmArray : AbstractDecoratable, ICollectionPropertyMapping
{
#region Implementation of IEntityPropertyMapping
@@ -9,6 +11,35 @@
get { return name; }
}
+ public string Access
+ {
+ get { return access; }
+ }
+
+ public bool OptimisticKock
+ {
+ get { return optimisticlock; }
+ }
+
#endregion
+
+ #region Implementation of IReferencePropertyMapping
+
+ public string Cascade
+ {
+ get { return cascade; }
+ }
+
+ #endregion
+
+ #region Overrides of AbstractDecoratable
+
+ protected override HbmMeta[] Metadatas
+ {
+ get { return meta ?? new HbmMeta[0]; }
+ }
+
+ #endregion
+
}
}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmBag.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmBag.cs 2009-11-29 20:47:58 UTC (rev 4874)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmBag.cs 2009-11-30 03:21:02 UTC (rev 4875)
@@ -1,6 +1,6 @@
namespace NHibernate.Cfg.MappingSchema
{
- public partial class HbmBag : ICollectionPropertyMapping
+ public partial class HbmBag : AbstractDecoratable, ICollectionPropertyMapping
{
#region Implementation of IEntityPropertyMapping
@@ -9,6 +9,34 @@
get { return name; }
}
+ public string Access
+ {
+ get { return access; }
+ }
+
+ public bool OptimisticKock
+ {
+ get { return optimisticlock; }
+ }
+
#endregion
+
+ #region Implementation of IReferencePropertyMapping
+
+ public string Cascade
+ {
+ get { return cascade; }
+ }
+
+ #endregion
+
+ #region Overrides of AbstractDecoratable
+
+ protected override HbmMeta[] Metadatas
+ {
+ get { return meta ?? new HbmMeta[0]; }
+ }
+
+ #endregion
}
}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmClass.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmClass.cs 2009-11-29 20:47:58 UTC (rev 4874)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmClass.cs 2009-11-30 03:21:02 UTC (rev 4875)
@@ -26,6 +26,26 @@
get { return Item1 as HbmTimestamp; }
}
+ public IEnumerable<HbmJoin> Joins
+ {
+ get { return Items1 != null ? Items1.OfType<HbmJoin>(): new HbmJoin[0]; }
+ }
+
+ public IEnumerable<HbmSubclass> Subclasses
+ {
+ get { return Items1 != null ? Items1.OfType<HbmSubclass>() : new HbmSubclass[0]; }
+ }
+
+ public IEnumerable<HbmJoinedSubclass> JoinedSubclasses
+ {
+ get { return Items1 != null ? Items1.OfType<HbmJoinedSubclass>() : new HbmJoinedSubclass[0]; }
+ }
+
+ public IEnumerable<HbmUnionSubclass> UnionSubclasses
+ {
+ get { return Items1 != null ? Items1.OfType<HbmUnionSubclass>() : new HbmUnionSubclass[0]; }
+ }
+
#region Implementation of IEntityMapping
protected override HbmMeta[] Metadatas
@@ -137,7 +157,7 @@
public IEnumerable<IEntityPropertyMapping> Properties
{
- get { return Items.Cast<IEntityPropertyMapping>(); }
+ get { return Items != null ? Items.Cast<IEntityPropertyMapping>(): new IEntityPropertyMapping[0]; }
}
#endregion
Modified: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmComponent.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmComponent.cs 2009-11-29 20:47:58 UTC (rev 4874)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmComponent.cs 2009-11-30 03:21:02 UTC (rev 4875)
@@ -4,7 +4,7 @@
namespace NHibernate.Cfg.MappingSchema
{
- public partial class HbmComponent : IEntityPropertyMapping, IPropertiesContainerMapping
+ public partial class HbmComponent : AbstractDecoratable, IEntityPropertyMapping, IPropertiesContainerMapping
{
#region Implementation of IEntityPropertyMapping
@@ -13,15 +13,35 @@
get { return name; }
}
+ public string Access
+ {
+ get { return access; }
+ }
+
+ public bool OptimisticKock
+ {
+ get { return optimisticlock; }
+ }
+
#endregion
#region Implementation of IPropertiesContainerMapping
public IEnumerable<IEntityPropertyMapping> Properties
{
- get { return Items.Cast<IEntityPropertyMapping>(); }
+ get { return Items != null ? Items.Cast<IEntityPropertyMapping>() : new IEntityPropertyMapping[0]; }
}
#endregion
+
+ #region Overrides of AbstractDecoratable
+
+ protected override HbmMeta[] Metadatas
+ {
+ get { return meta ?? new HbmMeta[0]; }
+ }
+
+ #endregion
+
}
}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmDynamicComponent.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmDynamicComponent.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmDynamicComponent.cs 2009-11-30 03:21:02 UTC (rev 4875)
@@ -0,0 +1,46 @@
+using System.Collections.Generic;
+using System.Linq;
+
+namespace NHibernate.Cfg.MappingSchema
+{
+ public partial class HbmDynamicComponent: AbstractDecoratable, IEntityPropertyMapping, IPropertiesContainerMapping
+ {
+ #region Implementation of IEntityPropertyMapping
+
+ public string Name
+ {
+ get { return name; }
+ }
+
+ public string Access
+ {
+ get { return access; }
+ }
+
+ public bool OptimisticKock
+ {
+ get { return optimisticlock; }
+ }
+
+ #endregion
+
+ #region Implementation of IPropertiesContainerMapping
+
+ public IEnumerable<IEntityPropertyMapping> Properties
+ {
+ get { return Items != null ? Items.Cast<IEntityPropertyMapping>() : new IEntityPropertyMapping[0]; }
+ }
+
+ #endregion
+
+ #region Overrides of AbstractDecoratable
+
+ protected override HbmMeta[] Metadatas
+ {
+ get { return new HbmMeta[0]; }
+ }
+
+ #endregion
+
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmExtensions.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmExtensions.cs 2009-11-29 20:47:58 UTC (rev 4874)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmExtensions.cs 2009-11-30 03:21:02 UTC (rev 4875)
@@ -1,4 +1,3 @@
-using System;
using NHibernate.Engine;
namespace NHibernate.Cfg.MappingSchema
Modified: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmIdbag.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmIdbag.cs 2009-11-29 20:47:58 UTC (rev 4874)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmIdbag.cs 2009-11-30 03:21:02 UTC (rev 4875)
@@ -1,6 +1,6 @@
namespace NHibernate.Cfg.MappingSchema
{
- public partial class HbmIdbag : ICollectionPropertyMapping
+ public partial class HbmIdbag : AbstractDecoratable, ICollectionPropertyMapping
{
#region Implementation of IEntityPropertyMapping
@@ -9,6 +9,34 @@
get { return name; }
}
+ public string Access
+ {
+ get { return access; }
+ }
+
+ public bool OptimisticKock
+ {
+ get { return optimisticlock; }
+ }
+
#endregion
+
+ #region Implementation of IReferencePropertyMapping
+
+ public string Cascade
+ {
+ get { return cascade; }
+ }
+
+ #endregion
+
+ #region Overrides of AbstractDecoratable
+
+ protected override HbmMeta[] Metadatas
+ {
+ get { return meta ?? new HbmMeta[0]; }
+ }
+
+ #endregion
}
}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmJoinedSubclass.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmJoinedSubclass.cs 2009-11-29 20:47:58 UTC (rev 4874)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmJoinedSubclass.cs 2009-11-30 03:21:02 UTC (rev 4875)
@@ -5,6 +5,11 @@
{
public partial class HbmJoinedSubclass : AbstractDecoratable, IEntityMapping
{
+ public IEnumerable<HbmJoinedSubclass> JoinedSubclasses
+ {
+ get { return joinedsubclass1 ?? new HbmJoinedSubclass[0]; }
+ }
+
#region Overrides of AbstractDecoratable
protected override HbmMeta[] Metadatas
@@ -110,7 +115,7 @@
public IEnumerable<IEntityPropertyMapping> Properties
{
- get { return Items.Cast<IEntityPropertyMapping>(); }
+ get { return Items != null ? Items.Cast<IEntityPropertyMapping>() : new IEntityPropertyMapping[0]; }
}
#endregion
Modified: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmList.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmList.cs 2009-11-29 20:47:58 UTC (rev 4874)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmList.cs 2009-11-30 03:21:02 UTC (rev 4875)
@@ -1,6 +1,6 @@
namespace NHibernate.Cfg.MappingSchema
{
- public partial class HbmList : ICollectionPropertyMapping
+ public partial class HbmList : AbstractDecoratable, ICollectionPropertyMapping
{
#region Implementation of IEntityPropertyMapping
@@ -9,6 +9,35 @@
get { return name; }
}
+ public string Access
+ {
+ get { return access; }
+ }
+
+ public bool OptimisticKock
+ {
+ get { return optimisticlock; }
+ }
+
#endregion
+
+ #region Implementation of IReferencePropertyMapping
+
+ public string Cascade
+ {
+ get { return cascade; }
+ }
+
+ #endregion
+
+ #region Overrides of AbstractDecoratable
+
+ protected override HbmMeta[] Metadatas
+ {
+ get { return meta ?? new HbmMeta[0]; }
+ }
+
+ #endregion
+
}
}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmManyToOne.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmManyToOne.cs 2009-11-29 20:47:58 UTC (rev 4874)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmManyToOne.cs 2009-11-30 03:21:02 UTC (rev 4875)
@@ -1,6 +1,8 @@
+using System;
+
namespace NHibernate.Cfg.MappingSchema
{
- public partial class HbmManyToOne : IEntityPropertyMapping
+ public partial class HbmManyToOne : AbstractDecoratable, IEntityPropertyMapping
{
#region Implementation of IEntityPropertyMapping
@@ -9,6 +11,26 @@
get { return name; }
}
+ public string Access
+ {
+ get { return access; }
+ }
+
+ public bool OptimisticKock
+ {
+ get { return optimisticlock; }
+ }
+
#endregion
+
+ #region Overrides of AbstractDecoratable
+
+ protected override HbmMeta[] Metadatas
+ {
+ get { return meta ?? new HbmMeta[0]; }
+ }
+
+ #endregion
+
}
}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmMap.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmMap.cs 2009-11-29 20:47:58 UTC (rev 4874)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmMap.cs 2009-11-30 03:21:02 UTC (rev 4875)
@@ -1,6 +1,6 @@
namespace NHibernate.Cfg.MappingSchema
{
- public partial class HbmMap : ICollectionPropertyMapping
+ public partial class HbmMap : AbstractDecoratable, ICollectionPropertyMapping
{
#region Implementation of IEntityPropertyMapping
@@ -9,6 +9,35 @@
get { return name; }
}
+ public string Access
+ {
+ get { return access; }
+ }
+
+ public bool OptimisticKock
+ {
+ get { return optimisticlock; }
+ }
+
#endregion
+
+ #region Implementation of IReferencePropertyMapping
+
+ public string Cascade
+ {
+ get { return cascade; }
+ }
+
+ #endregion
+
+ #region Overrides of AbstractDecoratable
+
+ protected override HbmMeta[] Metadatas
+ {
+ get { return meta ?? new HbmMeta[0]; }
+ }
+
+ #endregion
+
}
}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmNaturalId.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmNaturalId.cs 2009-11-29 20:47:58 UTC (rev 4874)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmNaturalId.cs 2009-11-30 03:21:02 UTC (rev 4875)
@@ -10,7 +10,7 @@
public IEnumerable<IEntityPropertyMapping> Properties
{
- get { return Items.Cast<IEntityPropertyMapping>(); }
+ get { return Items != null ? Items.Cast<IEntityPropertyMapping>() : new IEntityPropertyMapping[0]; }
}
#endregion
Modified: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmOneToOne.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmOneToOne.cs 2009-11-29 20:47:58 UTC (rev 4874)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmOneToOne.cs 2009-11-30 03:21:02 UTC (rev 4875)
@@ -1,6 +1,6 @@
namespace NHibernate.Cfg.MappingSchema
{
- public partial class HbmOneToOne : IEntityPropertyMapping
+ public partial class HbmOneToOne : AbstractDecoratable, IEntityPropertyMapping
{
#region Implementation of IEntityPropertyMapping
@@ -9,6 +9,26 @@
get { return name; }
}
+ public string Access
+ {
+ get { return access; }
+ }
+
+ public bool OptimisticKock
+ {
+ get { return true; }
+ }
+
#endregion
+
+ #region Overrides of AbstractDecoratable
+
+ protected override HbmMeta[] Metadatas
+ {
+ get { return meta ?? new HbmMeta[0]; }
+ }
+
+ #endregion
+
}
}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmPrimitiveArray.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmPrimitiveArray.cs 2009-11-29 20:47:58 UTC (rev 4874)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmPrimitiveArray.cs 2009-11-30 03:21:02 UTC (rev 4875)
@@ -1,6 +1,6 @@
namespace NHibernate.Cfg.MappingSchema
{
- public partial class HbmPrimitiveArray : ICollectionPropertyMapping
+ public partial class HbmPrimitiveArray : AbstractDecoratable, ICollectionPropertyMapping
{
#region Implementation of IEntityPropertyMapping
@@ -9,7 +9,35 @@
get { return name; }
}
+ public string Access
+ {
+ get { return access; }
+ }
+
+ public bool OptimisticKock
+ {
+ get { return optimisticlock; }
+ }
+
#endregion
-
+
+ #region Implementation of IReferencePropertyMapping
+
+ public string Cascade
+ {
+ get { return "none"; }
+ }
+
+ #endregion
+
+ #region Overrides of AbstractDecoratable
+
+ protected override HbmMeta[] Metadatas
+ {
+ get { return meta ?? new HbmMeta[0]; }
+ }
+
+ #endregion
+
}
}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmProperty.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmProperty.cs 2009-11-29 20:47:58 UTC (rev 4874)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmProperty.cs 2009-11-30 03:21:02 UTC (rev 4875)
@@ -1,6 +1,6 @@
namespace NHibernate.Cfg.MappingSchema
{
- public partial class HbmProperty : IEntityPropertyMapping
+ public partial class HbmProperty : AbstractDecoratable, IEntityPropertyMapping
{
#region Implementation of IEntityPropertyMapping
@@ -9,6 +9,25 @@
get { return name; }
}
+ public string Access
+ {
+ get { return access; }
+ }
+
+ public bool OptimisticKock
+ {
+ get { return optimisticlock; }
+ }
+
#endregion
+
+ #region Overrides of AbstractDecoratable
+
+ protected override HbmMeta[] Metadatas
+ {
+ get { return meta ?? new HbmMeta[0]; }
+ }
+
+ #endregion
}
}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmSet.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmSet.cs 2009-11-29 20:47:58 UTC (rev 4874)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmSet.cs 2009-11-30 03:21:02 UTC (rev 4875)
@@ -1,6 +1,6 @@
namespace NHibernate.Cfg.MappingSchema
{
- public partial class HbmSet : ICollectionPropertyMapping
+ public partial class HbmSet : AbstractDecoratable, ICollectionPropertyMapping
{
#region Implementation of IEntityPropertyMapping
@@ -9,6 +9,35 @@
get { return name; }
}
- #endregion
+ public string Access
+ {
+ get { return access; }
+ }
+
+ public bool OptimisticKock
+ {
+ get { return optimisticlock; }
+ }
+
+ #endregion
+
+ #region Implementation of IReferencePropertyMapping
+
+ public string Cascade
+ {
+ get { return cascade; }
+ }
+
+ #endregion
+
+ #region Overrides of AbstractDecoratable
+
+ protected override HbmMeta[] Metadatas
+ {
+ get { return meta ?? new HbmMeta[0]; }
+ }
+
+ #endregion
+
}
}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmSubclass.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmSubclass.cs 2009-11-29 20:47:58 UTC (rev 4874)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmSubclass.cs 2009-11-30 03:21:02 UTC (rev 4875)
@@ -5,6 +5,16 @@
{
public partial class HbmSubclass : AbstractDecoratable, IEntityMapping, IEntityDiscriminableMapping
{
+ public IEnumerable<HbmJoin> Joins
+ {
+ get { return join ?? new HbmJoin[0]; }
+ }
+
+ public IEnumerable<HbmSubclass> Subclasses
+ {
+ get { return subclass1 ?? new HbmSubclass[0]; }
+ }
+
#region Overrides of AbstractDecoratable
protected override HbmMeta[] Metadatas
@@ -120,7 +130,7 @@
public IEnumerable<IEntityPropertyMapping> Properties
{
- get { return Items.Cast<IEntityPropertyMapping>(); }
+ get { return Items != null ? Items.Cast<IEntityPropertyMapping>() : new IEntityPropertyMapping[0]; }
}
#endregion
Modified: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmUnionSubclass.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmUnionSubclass.cs 2009-11-29 20:47:58 UTC (rev 4874)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmUnionSubclass.cs 2009-11-30 03:21:02 UTC (rev 4875)
@@ -5,6 +5,11 @@
{
public partial class HbmUnionSubclass : AbstractDecoratable, IEntityMapping
{
+ public IEnumerable<HbmUnionSubclass> UnionSubclasses
+ {
+ get { return unionsubclass1 ?? new HbmUnionSubclass[0]; }
+ }
+
#region Overrides of AbstractDecoratable
protected override HbmMeta[] Metadatas
@@ -111,7 +116,7 @@
public IEnumerable<IEntityPropertyMapping> Properties
{
- get { return Items.Cast<IEntityPropertyMapping>(); }
+ get { return Items != null ? Items.Cast<IEntityPropertyMapping>() : new IEntityPropertyMapping[0]; }
}
#endregion
Modified: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/ICollectionPropertyMapping.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/ICollectionPropertyMapping.cs 2009-11-29 20:47:58 UTC (rev 4874)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/ICollectionPropertyMapping.cs 2009-11-30 03:21:02 UTC (rev 4875)
@@ -1,6 +1,6 @@
namespace NHibernate.Cfg.MappingSchema
{
- public interface ICollectionPropertyMapping: IEntityPropertyMapping
+ public interface ICollectionPropertyMapping : IEntityPropertyMapping, IReferencePropertyMapping
{
}
Modified: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/IEntityPropertyMapping.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/IEntityPropertyMapping.cs 2009-11-29 20:47:58 UTC (rev 4874)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/IEntityPropertyMapping.cs 2009-11-30 03:21:02 UTC (rev 4875)
@@ -1,7 +1,9 @@
namespace NHibernate.Cfg.MappingSchema
{
- public interface IEntityPropertyMapping
+ public interface IEntityPropertyMapping: IDecoratable
{
string Name { get; }
+ string Access { get; }
+ bool OptimisticKock { get; }
}
}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/IReferencePropertyMapping.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/IReferencePropertyMapping.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/IReferencePropertyMapping.cs 2009-11-30 03:21:02 UTC (rev 4875)
@@ -0,0 +1,7 @@
+namespace NHibernate.Cfg.MappingSchema
+{
+ public interface IReferencePropertyMapping
+ {
+ string Cascade { get; }
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/Binder.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/Binder.cs 2009-11-29 20:47:58 UTC (rev 4874)
+++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/Binder.cs 2009-11-30 03:21:02 UTC (rev 4875)
@@ -25,14 +25,6 @@
protected readonly Mappings mappings;
- protected Binder(Binder parent)
- {
- if (parent == null)
- throw new ArgumentNullException("parent");
-
- mappings = parent.mappings;
- }
-
protected Binder(Mappings mappings)
{
if (mappings == null)
@@ -41,6 +33,11 @@
this.mappings = mappings;
}
+ public Mappings Mappings
+ {
+ get { return mappings; }
+ }
+
/// <summary>
/// Converts a partial class name into a fully qualified one
/// </summary>
Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs 2009-11-29 20:47:58 UTC (rev 4874)
+++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs 2009-11-30 03:21:02 UTC (rev 4875)
@@ -16,127 +16,20 @@
protected readonly Dialect.Dialect dialect;
protected readonly XmlNamespaceManager namespaceManager;
- protected ClassBinder(Binder parent, XmlNamespaceManager namespaceManager, Dialect.Dialect dialect)
- : base(parent)
+ protected ClassBinder(Mappings mappings, XmlNamespaceManager namespaceManager, Dialect.Dialect dialect)
+ : base(mappings)
{
this.dialect = dialect;
this.namespaceManager = namespaceManager;
}
protected ClassBinder(ClassBinder parent)
- : base(parent)
+ : base(parent.Mappings)
{
dialect = parent.dialect;
namespaceManager = parent.namespaceManager;
}
- protected void PropertiesFromXML(XmlNode node, PersistentClass model, IDictionary<string, MetaAttribute> inheritedMetas)
- {
- PropertiesFromXML(node, model, inheritedMetas, null, true, true, false);
- }
-
- protected void PropertiesFromXML(XmlNode node, PersistentClass model, IDictionary<string, MetaAttribute> inheritedMetas, UniqueKey uniqueKey, bool mutable, bool nullable, bool naturalId)
- {
- string entityName = model.EntityName;
-
- Table table = model.Table;
-
- foreach (XmlNode subnode in node.ChildNodes)
- {
- //I am only concerned with elements that are from the nhibernate namespace
- if (subnode.NamespaceURI != MappingSchemaXMLNS)
- continue;
-
- string name = subnode.LocalName; //.Name;
- string propertyName = GetPropertyName(subnode);
-
- IValue value = null;
- CollectionBinder collectionBinder = new CollectionBinder(this);
- if (collectionBinder.CanCreate(name))
- {
- Mapping.Collection collection = collectionBinder.Create(name, subnode, entityName, propertyName, model,
- model.MappedClass, inheritedMetas);
-
- mappings.AddCollection(collection);
- value = collection;
- }
- else if ("many-to-one".Equals(name))
- {
- value = new ManyToOne(table);
- BindManyToOne(subnode, (ManyToOne) value, propertyName, true);
- }
- else if ("any".Equals(name))
- {
- value = new Any(table);
- BindAny(subnode, (Any) value, true);
- }
- else if ("one-to-one".Equals(name))
- {
- value = new OneToOne(table, model);
- BindOneToOne(subnode, (OneToOne) value);
- }
- else if ("property".Equals(name))
- {
- value = new SimpleValue(table);
- BindSimpleValue(subnode, (SimpleValue) value, true, propertyName);
- }
- else if ("component".Equals(name) || "dynamic-component".Equals(name))
- {
- string subpath = StringHelper.Qualify(entityName, propertyName);
- // NH: Modified from H2.1 to allow specifying the type explicitly using class attribute
- System.Type reflectedClass = GetPropertyType(subnode, model.MappedClass, propertyName);
- value = new Component(model);
- BindComponent(subnode, (Component) value, reflectedClass, entityName, propertyName, subpath, true, inheritedMetas);
- }
- else if ("join".Equals(name))
- {
- Join join = new Join();
- join.PersistentClass = model;
- BindJoin(subnode, join, inheritedMetas);
- model.AddJoin(join);
- }
- else if ("subclass".Equals(name))
- new SubclassBinder(this).HandleSubclass(model, subnode, Deserialize<HbmSubclass>(subnode) , inheritedMetas);
-
- else if ("joined-subclass".Equals(name))
- new JoinedSubclassBinder(this).HandleJoinedSubclass(model, subnode, Deserialize<HbmJoinedSubclass>(subnode), inheritedMetas);
-
- else if ("union-subclass".Equals(name))
- new UnionSubclassBinder(this).HandleUnionSubclass(model, subnode, Deserialize<HbmUnionSubclass>(subnode), inheritedMetas);
-
- else if ("filter".Equals(name))
- ParseFilter(subnode, model);
- else if ("natural-id".Equals(name))
- {
- UniqueKey uk = new UniqueKey();
- uk.Name = "_UniqueKey";
- uk.Table = table;
- //by default, natural-ids are "immutable" (constant)
-
- bool mutableId = false;
- if (subnode.Attributes["mutable"] != null)
- {
- mutableId = "true".Equals(subnode.Attributes["mutable"]);
- }
-
- PropertiesFromXML(subnode, model, inheritedMetas, uk, mutableId, false, true);
- t...
[truncated message content] |
|
From: <ric...@us...> - 2009-11-30 13:28:14
|
Revision: 4876
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4876&view=rev
Author: ricbrown
Date: 2009-11-30 13:28:06 +0000 (Mon, 30 Nov 2009)
Log Message:
-----------
Refactored generic type naming for IQueryOver and removed a couple of compiler warnings.
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Criterion/Lambda/QueryOverFetchBuilder.cs
trunk/nhibernate/src/NHibernate/Criterion/Lambda/QueryOverJoinBuilder.cs
trunk/nhibernate/src/NHibernate/Criterion/Lambda/QueryOverLockBuilder.cs
trunk/nhibernate/src/NHibernate/Criterion/Lambda/QueryOverOrderBuilder.cs
trunk/nhibernate/src/NHibernate/Criterion/Lambda/QueryOverProjectionBuilder.cs
trunk/nhibernate/src/NHibernate/Criterion/Lambda/QueryOverRestrictionBuilder.cs
trunk/nhibernate/src/NHibernate/Criterion/Lambda/QueryOverSubqueryBuilder.cs
trunk/nhibernate/src/NHibernate/Criterion/Lambda/QueryOverSubqueryPropertyBuilder.cs
trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs
trunk/nhibernate/src/NHibernate/IQueryOver.cs
trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/LambdaFixtureBase.cs
Modified: trunk/nhibernate/src/NHibernate/Criterion/Lambda/QueryOverFetchBuilder.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Criterion/Lambda/QueryOverFetchBuilder.cs 2009-11-30 03:21:02 UTC (rev 4875)
+++ trunk/nhibernate/src/NHibernate/Criterion/Lambda/QueryOverFetchBuilder.cs 2009-11-30 13:28:06 UTC (rev 4876)
@@ -9,35 +9,35 @@
namespace NHibernate.Criterion
{
- public class QueryOverFetchBuilder<S,T> : QueryOverFetchBuilderBase<QueryOver<S,T>, S, T>
+ public class QueryOverFetchBuilder<TRoot,TSubType> : QueryOverFetchBuilderBase<QueryOver<TRoot,TSubType>, TRoot, TSubType>
{
- public QueryOverFetchBuilder(QueryOver<S,T> root, Expression<Func<S, object>> path)
+ public QueryOverFetchBuilder(QueryOver<TRoot,TSubType> root, Expression<Func<TRoot, object>> path)
: base(root, path) { }
}
- public class IQueryOverFetchBuilder<S,T> : QueryOverFetchBuilderBase<IQueryOver<S,T>, S, T>
+ public class IQueryOverFetchBuilder<TRoot,TSubType> : QueryOverFetchBuilderBase<IQueryOver<TRoot,TSubType>, TRoot, TSubType>
{
- public IQueryOverFetchBuilder(IQueryOver<S,T> root, Expression<Func<S, object>> path)
+ public IQueryOverFetchBuilder(IQueryOver<TRoot,TSubType> root, Expression<Func<TRoot, object>> path)
: base(root, path) { }
}
- public class QueryOverFetchBuilderBase<R, S, T> where R : IQueryOver<S,T>
+ public class QueryOverFetchBuilderBase<TReturn, TRoot, TSubType> where TReturn : IQueryOver<TRoot,TSubType>
{
- protected R root;
+ protected TReturn root;
protected string path;
- protected QueryOverFetchBuilderBase(R root, Expression<Func<S, object>> path)
+ protected QueryOverFetchBuilderBase(TReturn root, Expression<Func<TRoot, object>> path)
{
this.root = root;
this.path = ExpressionProcessor.FindMemberExpression(path.Body);
}
- public R Eager
+ public TReturn Eager
{
get
{
@@ -46,7 +46,7 @@
}
}
- public R Lazy
+ public TReturn Lazy
{
get
{
@@ -55,7 +55,7 @@
}
}
- public R Default
+ public TReturn Default
{
get
{
Modified: trunk/nhibernate/src/NHibernate/Criterion/Lambda/QueryOverJoinBuilder.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Criterion/Lambda/QueryOverJoinBuilder.cs 2009-11-30 03:21:02 UTC (rev 4875)
+++ trunk/nhibernate/src/NHibernate/Criterion/Lambda/QueryOverJoinBuilder.cs 2009-11-30 13:28:06 UTC (rev 4876)
@@ -9,118 +9,118 @@
namespace NHibernate.Criterion.Lambda
{
- public class QueryOverJoinBuilder<S,T> : QueryOverJoinBuilderBase<QueryOver<S,T>, S, T>
+ public class QueryOverJoinBuilder<TRoot,TSubType> : QueryOverJoinBuilderBase<QueryOver<TRoot,TSubType>, TRoot, TSubType>
{
- public QueryOverJoinBuilder(QueryOver<S,T> root, JoinType joinType) : base(root, joinType) { }
+ public QueryOverJoinBuilder(QueryOver<TRoot,TSubType> root, JoinType joinType) : base(root, joinType) { }
- public QueryOver<S,U> JoinQueryOver<U>(Expression<Func<T, U>> path)
+ public QueryOver<TRoot,U> JoinQueryOver<U>(Expression<Func<TSubType, U>> path)
{
return root.JoinQueryOver<U>(path, joinType);
}
- public QueryOver<S,U> JoinQueryOver<U>(Expression<Func<U>> path)
+ public QueryOver<TRoot,U> JoinQueryOver<U>(Expression<Func<U>> path)
{
return root.JoinQueryOver<U>(path, joinType);
}
- public QueryOver<S,U> JoinQueryOver<U>(Expression<Func<T, U>> path, Expression<Func<U>> alias)
+ public QueryOver<TRoot,U> JoinQueryOver<U>(Expression<Func<TSubType, U>> path, Expression<Func<U>> alias)
{
return root.JoinQueryOver<U>(path, alias, joinType);
}
- public QueryOver<S,U> JoinQueryOver<U>(Expression<Func<U>> path, Expression<Func<U>> alias)
+ public QueryOver<TRoot,U> JoinQueryOver<U>(Expression<Func<U>> path, Expression<Func<U>> alias)
{
return root.JoinQueryOver<U>(path, alias, joinType);
}
- public QueryOver<S,U> JoinQueryOver<U>(Expression<Func<T, IEnumerable<U>>> path)
+ public QueryOver<TRoot,U> JoinQueryOver<U>(Expression<Func<TSubType, IEnumerable<U>>> path)
{
return root.JoinQueryOver<U>(path, joinType);
}
- public QueryOver<S,U> JoinQueryOver<U>(Expression<Func<IEnumerable<U>>> path)
+ public QueryOver<TRoot,U> JoinQueryOver<U>(Expression<Func<IEnumerable<U>>> path)
{
return root.JoinQueryOver<U>(path, joinType);
}
- public QueryOver<S,U> JoinQueryOver<U>(Expression<Func<T, IEnumerable<U>>> path, Expression<Func<U>> alias)
+ public QueryOver<TRoot,U> JoinQueryOver<U>(Expression<Func<TSubType, IEnumerable<U>>> path, Expression<Func<U>> alias)
{
return root.JoinQueryOver<U>(path, alias, joinType);
}
- public QueryOver<S,U> JoinQueryOver<U>(Expression<Func<IEnumerable<U>>> path, Expression<Func<U>> alias)
+ public QueryOver<TRoot,U> JoinQueryOver<U>(Expression<Func<IEnumerable<U>>> path, Expression<Func<U>> alias)
{
return root.JoinQueryOver<U>(path, alias, joinType);
}
}
- public class IQueryOverJoinBuilder<S,T> : QueryOverJoinBuilderBase<IQueryOver<S,T>, S, T>
+ public class IQueryOverJoinBuilder<TRoot,TSubType> : QueryOverJoinBuilderBase<IQueryOver<TRoot,TSubType>, TRoot, TSubType>
{
- public IQueryOverJoinBuilder(IQueryOver<S,T> root, JoinType joinType) : base(root, joinType) { }
+ public IQueryOverJoinBuilder(IQueryOver<TRoot,TSubType> root, JoinType joinType) : base(root, joinType) { }
- public IQueryOver<S,U> JoinQueryOver<U>(Expression<Func<T, U>> path)
+ public IQueryOver<TRoot,U> JoinQueryOver<U>(Expression<Func<TSubType, U>> path)
{
return root.JoinQueryOver<U>(path, joinType);
}
- public IQueryOver<S,U> JoinQueryOver<U>(Expression<Func<U>> path)
+ public IQueryOver<TRoot,U> JoinQueryOver<U>(Expression<Func<U>> path)
{
return root.JoinQueryOver<U>(path, joinType);
}
- public IQueryOver<S,U> JoinQueryOver<U>(Expression<Func<T, U>> path, Expression<Func<U>> alias)
+ public IQueryOver<TRoot,U> JoinQueryOver<U>(Expression<Func<TSubType, U>> path, Expression<Func<U>> alias)
{
return root.JoinQueryOver<U>(path, alias, joinType);
}
- public IQueryOver<S,U> JoinQueryOver<U>(Expression<Func<U>> path, Expression<Func<U>> alias)
+ public IQueryOver<TRoot,U> JoinQueryOver<U>(Expression<Func<U>> path, Expression<Func<U>> alias)
{
return root.JoinQueryOver<U>(path, alias, joinType);
}
- public IQueryOver<S,U> JoinQueryOver<U>(Expression<Func<T, IEnumerable<U>>> path)
+ public IQueryOver<TRoot,U> JoinQueryOver<U>(Expression<Func<TSubType, IEnumerable<U>>> path)
{
return root.JoinQueryOver<U>(path, joinType);
}
- public IQueryOver<S,U> JoinQueryOver<U>(Expression<Func<IEnumerable<U>>> path)
+ public IQueryOver<TRoot,U> JoinQueryOver<U>(Expression<Func<IEnumerable<U>>> path)
{
return root.JoinQueryOver<U>(path, joinType);
}
- public IQueryOver<S,U> JoinQueryOver<U>(Expression<Func<T, IEnumerable<U>>> path, Expression<Func<U>> alias)
+ public IQueryOver<TRoot,U> JoinQueryOver<U>(Expression<Func<TSubType, IEnumerable<U>>> path, Expression<Func<U>> alias)
{
return root.JoinQueryOver<U>(path, alias, joinType);
}
- public IQueryOver<S,U> JoinQueryOver<U>(Expression<Func<IEnumerable<U>>> path, Expression<Func<U>> alias)
+ public IQueryOver<TRoot,U> JoinQueryOver<U>(Expression<Func<IEnumerable<U>>> path, Expression<Func<U>> alias)
{
return root.JoinQueryOver<U>(path, alias, joinType);
}
}
- public class QueryOverJoinBuilderBase<R, S, T> where R : IQueryOver<S,T>
+ public class QueryOverJoinBuilderBase<TReturn, TRoot, TSubType> where TReturn : IQueryOver<TRoot,TSubType>
{
- protected R root;
+ protected TReturn root;
protected JoinType joinType;
- public QueryOverJoinBuilderBase(R root, JoinType joinType)
+ public QueryOverJoinBuilderBase(TReturn root, JoinType joinType)
{
this.root = root;
this.joinType = joinType;
}
- public R JoinAlias(Expression<Func<T, object>> path, Expression<Func<object>> alias)
+ public TReturn JoinAlias(Expression<Func<TSubType, object>> path, Expression<Func<object>> alias)
{
- return (R)root.JoinAlias(path, alias, joinType);
+ return (TReturn)root.JoinAlias(path, alias, joinType);
}
- public R JoinAlias(Expression<Func<object>> path, Expression<Func<object>> alias)
+ public TReturn JoinAlias(Expression<Func<object>> path, Expression<Func<object>> alias)
{
- return (R)root.JoinAlias(path, alias, joinType);
+ return (TReturn)root.JoinAlias(path, alias, joinType);
}
}
Modified: trunk/nhibernate/src/NHibernate/Criterion/Lambda/QueryOverLockBuilder.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Criterion/Lambda/QueryOverLockBuilder.cs 2009-11-30 03:21:02 UTC (rev 4875)
+++ trunk/nhibernate/src/NHibernate/Criterion/Lambda/QueryOverLockBuilder.cs 2009-11-30 13:28:06 UTC (rev 4876)
@@ -9,29 +9,29 @@
namespace NHibernate.Criterion.Lambda
{
- public class QueryOverLockBuilder<S,T> : QueryOverLockBuilderBase<QueryOver<S,T>, S, T>
+ public class QueryOverLockBuilder<TRoot,TSubType> : QueryOverLockBuilderBase<QueryOver<TRoot,TSubType>, TRoot, TSubType>
{
- public QueryOverLockBuilder(QueryOver<S,T> root, Expression<Func<object>> alias)
+ public QueryOverLockBuilder(QueryOver<TRoot,TSubType> root, Expression<Func<object>> alias)
: base(root, alias) { }
}
- public class IQueryOverLockBuilder<S,T> : QueryOverLockBuilderBase<IQueryOver<S,T>, S, T>
+ public class IQueryOverLockBuilder<TRoot,TSubType> : QueryOverLockBuilderBase<IQueryOver<TRoot,TSubType>, TRoot, TSubType>
{
- public IQueryOverLockBuilder(IQueryOver<S,T> root, Expression<Func<object>> alias)
+ public IQueryOverLockBuilder(IQueryOver<TRoot,TSubType> root, Expression<Func<object>> alias)
: base(root, alias) { }
}
- public class QueryOverLockBuilderBase<R, S, T> where R : IQueryOver<S,T>
+ public class QueryOverLockBuilderBase<TReturn, TRoot, TSubType> where TReturn : IQueryOver<TRoot,TSubType>
{
- protected R root;
+ protected TReturn root;
protected string alias;
- protected QueryOverLockBuilderBase(R root, Expression<Func<object>> alias)
+ protected QueryOverLockBuilderBase(TReturn root, Expression<Func<object>> alias)
{
this.root = root;
@@ -47,7 +47,7 @@
root.UnderlyingCriteria.SetLockMode(lockMode);
}
- public R Force
+ public TReturn Force
{
get
{
@@ -56,7 +56,7 @@
}
}
- public R None
+ public TReturn None
{
get
{
@@ -65,7 +65,7 @@
}
}
- public R Read
+ public TReturn Read
{
get
{
@@ -74,7 +74,7 @@
}
}
- public R Upgrade
+ public TReturn Upgrade
{
get
{
@@ -83,7 +83,7 @@
}
}
- public R UpgradeNoWait
+ public TReturn UpgradeNoWait
{
get
{
@@ -92,7 +92,7 @@
}
}
- public R Write
+ public TReturn Write
{
get
{
Modified: trunk/nhibernate/src/NHibernate/Criterion/Lambda/QueryOverOrderBuilder.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Criterion/Lambda/QueryOverOrderBuilder.cs 2009-11-30 03:21:02 UTC (rev 4875)
+++ trunk/nhibernate/src/NHibernate/Criterion/Lambda/QueryOverOrderBuilder.cs 2009-11-30 13:28:06 UTC (rev 4876)
@@ -9,47 +9,47 @@
namespace NHibernate.Criterion.Lambda
{
- public class QueryOverOrderBuilder<S,T> : QueryOverOrderBuilderBase<QueryOver<S,T>, S, T>
+ public class QueryOverOrderBuilder<TRoot,TSubType> : QueryOverOrderBuilderBase<QueryOver<TRoot,TSubType>, TRoot, TSubType>
{
- public QueryOverOrderBuilder(QueryOver<S,T> root, Expression<Func<T, object>> path) : base(root, path)
+ public QueryOverOrderBuilder(QueryOver<TRoot,TSubType> root, Expression<Func<TSubType, object>> path) : base(root, path)
{}
- public QueryOverOrderBuilder(QueryOver<S,T> root, Expression<Func<object>> path) : base(root, path)
+ public QueryOverOrderBuilder(QueryOver<TRoot,TSubType> root, Expression<Func<object>> path) : base(root, path)
{}
}
- public class IQueryOverOrderBuilder<S,T> : QueryOverOrderBuilderBase<IQueryOver<S,T>, S, T>
+ public class IQueryOverOrderBuilder<TRoot,TSubType> : QueryOverOrderBuilderBase<IQueryOver<TRoot,TSubType>, TRoot, TSubType>
{
- public IQueryOverOrderBuilder(IQueryOver<S,T> root, Expression<Func<T, object>> path) : base(root, path)
+ public IQueryOverOrderBuilder(IQueryOver<TRoot,TSubType> root, Expression<Func<TSubType, object>> path) : base(root, path)
{}
- public IQueryOverOrderBuilder(IQueryOver<S,T> root, Expression<Func<object>> path) : base(root, path)
+ public IQueryOverOrderBuilder(IQueryOver<TRoot,TSubType> root, Expression<Func<object>> path) : base(root, path)
{}
}
- public class QueryOverOrderBuilderBase<R, S, T> where R : IQueryOver<S, T>
+ public class QueryOverOrderBuilderBase<TReturn, TRoot, TSubType> where TReturn : IQueryOver<TRoot, TSubType>
{
- protected R root;
+ protected TReturn root;
protected LambdaExpression path;
- protected QueryOverOrderBuilderBase(R root, Expression<Func<T, object>> path)
+ protected QueryOverOrderBuilderBase(TReturn root, Expression<Func<TSubType, object>> path)
{
this.root = root;
this.path = path;
}
- protected QueryOverOrderBuilderBase(R root, Expression<Func<object>> path)
+ protected QueryOverOrderBuilderBase(TReturn root, Expression<Func<object>> path)
{
this.root = root;
this.path = path;
}
- public R Asc
+ public TReturn Asc
{
get
{
@@ -58,7 +58,7 @@
}
}
- public R Desc
+ public TReturn Desc
{
get
{
Modified: trunk/nhibernate/src/NHibernate/Criterion/Lambda/QueryOverProjectionBuilder.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Criterion/Lambda/QueryOverProjectionBuilder.cs 2009-11-30 03:21:02 UTC (rev 4875)
+++ trunk/nhibernate/src/NHibernate/Criterion/Lambda/QueryOverProjectionBuilder.cs 2009-11-30 13:28:06 UTC (rev 4876)
@@ -9,15 +9,15 @@
namespace NHibernate.Criterion.Lambda
{
- public class QueryOverProjectionBuilder<R, S, T>
+ public class QueryOverProjectionBuilder<TReturn, TRoot, TSubType>
{
- private R fluentReturn;
- private IQueryOver<S,T> criteria;
+ private TReturn fluentReturn;
+ private IQueryOver<TRoot,TSubType> criteria;
private ProjectionList projectionList;
private IProjection lastProjection = null;
- public QueryOverProjectionBuilder(R fluentReturn, IQueryOver<S,T> criteria)
+ public QueryOverProjectionBuilder(TReturn fluentReturn, IQueryOver<TRoot,TSubType> criteria)
{
this.fluentReturn = fluentReturn;
this.criteria = criteria;
@@ -39,7 +39,7 @@
/// <summary>
/// Create the ProjectionList and return to the query
/// </summary>
- public R EndSelect
+ public TReturn EndSelect
{
get
{
@@ -52,7 +52,7 @@
/// <summary>
/// Create an alias for the previous projection
/// </summary>
- public QueryOverProjectionBuilder<R, S, T> WithAlias(Expression<Func<object>> alias)
+ public QueryOverProjectionBuilder<TReturn, TRoot, TSubType> WithAlias(Expression<Func<object>> alias)
{
string aliasContainer = ExpressionProcessor.FindMemberExpression(alias.Body);
lastProjection = Projections.Alias(lastProjection, aliasContainer);
@@ -62,7 +62,7 @@
/// <summary>
/// Select an arbitrary projection
/// </summary>
- public QueryOverProjectionBuilder<R, S, T> Select(IProjection projection)
+ public QueryOverProjectionBuilder<TReturn, TRoot, TSubType> Select(IProjection projection)
{
PushProjection(projection);
return this;
@@ -71,7 +71,7 @@
/// <summary>
/// A property average value
/// </summary>
- public QueryOverProjectionBuilder<R, S, T> SelectAvg(Expression<Func<T, object>> expression)
+ public QueryOverProjectionBuilder<TReturn, TRoot, TSubType> SelectAvg(Expression<Func<TSubType, object>> expression)
{
PushProjection(Projections.Avg(expression));
return this;
@@ -80,7 +80,7 @@
/// <summary>
/// A property average value
/// </summary>
- public QueryOverProjectionBuilder<R, S, T> SelectAvg(Expression<Func<object>> expression)
+ public QueryOverProjectionBuilder<TReturn, TRoot, TSubType> SelectAvg(Expression<Func<object>> expression)
{
PushProjection(Projections.Avg(expression));
return this;
@@ -89,7 +89,7 @@
/// <summary>
/// A property value count
/// </summary>
- public QueryOverProjectionBuilder<R, S, T> SelectCount(Expression<Func<T, object>> expression)
+ public QueryOverProjectionBuilder<TReturn, TRoot, TSubType> SelectCount(Expression<Func<TSubType, object>> expression)
{
PushProjection(Projections.Count(expression));
return this;
@@ -98,7 +98,7 @@
/// <summary>
/// A property value count
/// </summary>
- public QueryOverProjectionBuilder<R, S, T> SelectCount(Expression<Func<object>> expression)
+ public QueryOverProjectionBuilder<TReturn, TRoot, TSubType> SelectCount(Expression<Func<object>> expression)
{
PushProjection(Projections.Count(expression));
return this;
@@ -107,7 +107,7 @@
/// <summary>
/// A distinct property value count
/// </summary>
- public QueryOverProjectionBuilder<R, S, T> SelectCountDistinct(Expression<Func<T, object>> expression)
+ public QueryOverProjectionBuilder<TReturn, TRoot, TSubType> SelectCountDistinct(Expression<Func<TSubType, object>> expression)
{
PushProjection(Projections.CountDistinct(expression));
return this;
@@ -116,7 +116,7 @@
/// <summary>
/// A distinct property value count
/// </summary>
- public QueryOverProjectionBuilder<R, S, T> SelectCountDistinct(Expression<Func<object>> expression)
+ public QueryOverProjectionBuilder<TReturn, TRoot, TSubType> SelectCountDistinct(Expression<Func<object>> expression)
{
PushProjection(Projections.CountDistinct(expression));
return this;
@@ -125,7 +125,7 @@
/// <summary>
/// A grouping property value
/// </summary>
- public QueryOverProjectionBuilder<R, S, T> SelectGroup(Expression<Func<T, object>> expression)
+ public QueryOverProjectionBuilder<TReturn, TRoot, TSubType> SelectGroup(Expression<Func<TSubType, object>> expression)
{
PushProjection(Projections.Group(expression));
return this;
@@ -134,7 +134,7 @@
/// <summary>
/// A grouping property value
/// </summary>
- public QueryOverProjectionBuilder<R, S, T> SelectGroup(Expression<Func<object>> expression)
+ public QueryOverProjectionBuilder<TReturn, TRoot, TSubType> SelectGroup(Expression<Func<object>> expression)
{
PushProjection(Projections.Group(expression));
return this;
@@ -143,7 +143,7 @@
/// <summary>
/// A property maximum value
/// </summary>
- public QueryOverProjectionBuilder<R, S, T> SelectMax(Expression<Func<T, object>> expression)
+ public QueryOverProjectionBuilder<TReturn, TRoot, TSubType> SelectMax(Expression<Func<TSubType, object>> expression)
{
PushProjection(Projections.Max(expression));
return this;
@@ -152,7 +152,7 @@
/// <summary>
/// A property maximum value
/// </summary>
- public QueryOverProjectionBuilder<R, S, T> SelectMax(Expression<Func<object>> expression)
+ public QueryOverProjectionBuilder<TReturn, TRoot, TSubType> SelectMax(Expression<Func<object>> expression)
{
PushProjection(Projections.Max(expression));
return this;
@@ -161,7 +161,7 @@
/// <summary>
/// A property minimum value
/// </summary>
- public QueryOverProjectionBuilder<R, S, T> SelectMin(Expression<Func<T, object>> expression)
+ public QueryOverProjectionBuilder<TReturn, TRoot, TSubType> SelectMin(Expression<Func<TSubType, object>> expression)
{
PushProjection(Projections.Min(expression));
return this;
@@ -170,7 +170,7 @@
/// <summary>
/// A property minimum value
/// </summary>
- public QueryOverProjectionBuilder<R, S, T> SelectMin(Expression<Func<object>> expression)
+ public QueryOverProjectionBuilder<TReturn, TRoot, TSubType> SelectMin(Expression<Func<object>> expression)
{
PushProjection(Projections.Min(expression));
return this;
@@ -179,7 +179,7 @@
/// <summary>
/// A projected property value
/// </summary>
- public QueryOverProjectionBuilder<R, S, T> Select(Expression<Func<T, object>> expression)
+ public QueryOverProjectionBuilder<TReturn, TRoot, TSubType> Select(Expression<Func<TSubType, object>> expression)
{
PushProjection(Projections.Property(expression));
return this;
@@ -188,13 +188,13 @@
/// <summary>
/// A projected property value
/// </summary>
- public QueryOverProjectionBuilder<R, S, T> Select(Expression<Func<object>> expression)
+ public QueryOverProjectionBuilder<TReturn, TRoot, TSubType> Select(Expression<Func<object>> expression)
{
PushProjection(Projections.Property(expression));
return this;
}
- public QueryOverProjectionBuilder<R, S, T> SelectSubQuery<U>(QueryOver<U> detachedQueryOver)
+ public QueryOverProjectionBuilder<TReturn, TRoot, TSubType> SelectSubQuery<U>(QueryOver<U> detachedQueryOver)
{
PushProjection(Projections.SubQuery(detachedQueryOver));
return this;
@@ -203,7 +203,7 @@
/// <summary>
/// A property value sum
/// </summary>
- public QueryOverProjectionBuilder<R, S, T> SelectSum(Expression<Func<T, object>> expression)
+ public QueryOverProjectionBuilder<TReturn, TRoot, TSubType> SelectSum(Expression<Func<TSubType, object>> expression)
{
PushProjection(Projections.Sum(expression));
return this;
@@ -212,7 +212,7 @@
/// <summary>
/// A property value sum
/// </summary>
- public QueryOverProjectionBuilder<R, S, T> SelectSum(Expression<Func<object>> expression)
+ public QueryOverProjectionBuilder<TReturn, TRoot, TSubType> SelectSum(Expression<Func<object>> expression)
{
PushProjection(Projections.Sum(expression));
return this;
Modified: trunk/nhibernate/src/NHibernate/Criterion/Lambda/QueryOverRestrictionBuilder.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Criterion/Lambda/QueryOverRestrictionBuilder.cs 2009-11-30 03:21:02 UTC (rev 4875)
+++ trunk/nhibernate/src/NHibernate/Criterion/Lambda/QueryOverRestrictionBuilder.cs 2009-11-30 13:28:06 UTC (rev 4876)
@@ -10,51 +10,51 @@
namespace NHibernate.Criterion.Lambda
{
- public class QueryOverRestrictionBuilder<S,T> : QueryOverRestrictionBuilderBase<QueryOver<S,T>, S, T>
+ public class QueryOverRestrictionBuilder<TRoot,TSubType> : QueryOverRestrictionBuilderBase<QueryOver<TRoot,TSubType>, TRoot, TSubType>
{
- public QueryOverRestrictionBuilder(QueryOver<S,T> root, string propertyName)
+ public QueryOverRestrictionBuilder(QueryOver<TRoot,TSubType> root, string propertyName)
: base(root, propertyName) { }
}
- public class IQueryOverRestrictionBuilder<S,T> : QueryOverRestrictionBuilderBase<IQueryOver<S,T>, S, T>
+ public class IQueryOverRestrictionBuilder<TRoot,TSubType> : QueryOverRestrictionBuilderBase<IQueryOver<TRoot,TSubType>, TRoot, TSubType>
{
- public IQueryOverRestrictionBuilder(IQueryOver<S,T> root, string propertyName)
+ public IQueryOverRestrictionBuilder(IQueryOver<TRoot,TSubType> root, string propertyName)
: base(root, propertyName) { }
}
- public class QueryOverRestrictionBuilderBase<R,S,T>
- where R : IQueryOver<S,T>
+ public class QueryOverRestrictionBuilderBase<TReturn,TRoot,TSubType>
+ where TReturn : IQueryOver<TRoot,TSubType>
{
public class LambdaBetweenBuilder
{
- private R root;
+ private TReturn root;
private string propertyName;
private object lo;
- public LambdaBetweenBuilder(R root, string propertyName, object lo)
+ public LambdaBetweenBuilder(TReturn root, string propertyName, object lo)
{
this.root = root;
this.propertyName = propertyName;
this.lo = lo;
}
- public R And(object hi)
+ public TReturn And(object hi)
{
- return (R)root.And(Restrictions.Between(propertyName, lo, hi));
+ return (TReturn)root.And(Restrictions.Between(propertyName, lo, hi));
}
}
- private R root;
+ private TReturn root;
private string propertyName;
/// <summary>
/// Constructed with property name
/// </summary>
- public QueryOverRestrictionBuilderBase(R root, string propertyName)
+ public QueryOverRestrictionBuilderBase(TReturn root, string propertyName)
{
this.root = root;
this.propertyName = propertyName;
@@ -71,97 +71,97 @@
/// <summary>
/// Apply an "in" constraint to the named property
/// </summary>
- public R IsIn(ICollection values)
+ public TReturn IsIn(ICollection values)
{
- return (R)root.And(Restrictions.In(propertyName, values));
+ return (TReturn)root.And(Restrictions.In(propertyName, values));
}
/// <summary>
/// Apply an "in" constraint to the named property
/// </summary>
- public R IsIn(object[] values)
+ public TReturn IsIn(object[] values)
{
- return (R)root.And(Restrictions.In(propertyName, values));
+ return (TReturn)root.And(Restrictions.In(propertyName, values));
}
/// <summary>
/// Apply an "in" constraint to the named property
/// </summary>
- public R IsInG<T>(ICollection<T> values)
+ public TReturn IsInG<T>(ICollection<T> values)
{
- return (R)root.And(Restrictions.InG(propertyName, values));
+ return (TReturn)root.And(Restrictions.InG(propertyName, values));
}
/// <summary>
/// A case-insensitive "like", similar to Postgres "ilike" operator
/// </summary>
- public R IsInsensitiveLike(object value)
+ public TReturn IsInsensitiveLike(object value)
{
- return (R)root.And(Restrictions.InsensitiveLike(propertyName, value));
+ return (TReturn)root.And(Restrictions.InsensitiveLike(propertyName, value));
}
/// <summary>
/// A case-insensitive "like", similar to Postgres "ilike" operator
/// </summary>
- public R IsInsensitiveLike(string value, MatchMode matchMode)
+ public TReturn IsInsensitiveLike(string value, MatchMode matchMode)
{
- return (R)root.And(Restrictions.InsensitiveLike(propertyName, value, matchMode));
+ return (TReturn)root.And(Restrictions.InsensitiveLike(propertyName, value, matchMode));
}
/// <summary>
/// Apply an "is empty" constraint to the named property
/// </summary>
- public R IsEmpty
+ public TReturn IsEmpty
{
- get { return (R)root.And(Restrictions.IsEmpty(propertyName)); }
+ get { return (TReturn)root.And(Restrictions.IsEmpty(propertyName)); }
}
/// <summary>
/// Apply a "not is empty" constraint to the named property
/// </summary>
- public R IsNotEmpty
+ public TReturn IsNotEmpty
{
- get { return (R)root.And(Restrictions.IsNotEmpty(propertyName)); }
+ get { return (TReturn)root.And(Restrictions.IsNotEmpty(propertyName)); }
}
/// <summary>
/// Apply an "is null" constraint to the named property
/// </summary>
- public R IsNull
+ public TReturn IsNull
{
- get { return (R)root.And(Restrictions.IsNull(propertyName)); }
+ get { return (TReturn)root.And(Restrictions.IsNull(propertyName)); }
}
/// <summary>
/// Apply an "not is null" constraint to the named property
/// </summary>
- public R IsNotNull
+ public TReturn IsNotNull
{
- get { return (R)root.And(Restrictions.IsNotNull(propertyName)); }
+ get { return (TReturn)root.And(Restrictions.IsNotNull(propertyName)); }
}
/// <summary>
/// Apply a "like" constraint to the named property
/// </summary>
- public R IsLike(object value)
+ public TReturn IsLike(object value)
{
- return (R)root.And(Restrictions.Like(propertyName, value));
+ return (TReturn)root.And(Restrictions.Like(propertyName, value));
}
/// <summary>
/// Apply a "like" constraint to the named property
/// </summary>
- public R IsLike(string value, MatchMode matchMode)
+ public TReturn IsLike(string value, MatchMode matchMode)
{
- return (R)root.And(Restrictions.Like(propertyName, value, matchMode));
+ return (TReturn)root.And(Restrictions.Like(propertyName, value, matchMode));
}
/// <summary>
/// Apply a "like" constraint to the named property
/// </summary>
- public R IsLike(string value, MatchMode matchMode, char? escapeChar)
+ public TReturn IsLike(string value, MatchMode matchMode, char? escapeChar)
{
- return (R)root.And(Restrictions.Like(propertyName, value, matchMode, escapeChar));
+ return (TReturn)root.And(Restrictions.Like(propertyName, value, matchMode, escapeChar));
}
}
Modified: trunk/nhibernate/src/NHibernate/Criterion/Lambda/QueryOverSubqueryBuilder.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Criterion/Lambda/QueryOverSubqueryBuilder.cs 2009-11-30 03:21:02 UTC (rev 4875)
+++ trunk/nhibernate/src/NHibernate/Criterion/Lambda/QueryOverSubqueryBuilder.cs 2009-11-30 13:28:06 UTC (rev 4876)
@@ -9,30 +9,30 @@
namespace NHibernate.Criterion.Lambda
{
- public class QueryOverSubqueryBuilder<S,T> : QueryOverSubqueryBuilderBase<QueryOver<S,T>, S, T, QueryOverSubqueryPropertyBuilder<S,T>>
+ public ...
[truncated message content] |
|
From: <ric...@us...> - 2009-11-30 17:10:51
|
Revision: 4877
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4877&view=rev
Author: ricbrown
Date: 2009-11-30 17:10:42 +0000 (Mon, 30 Nov 2009)
Log Message:
-----------
Added integration example demonstrating multiple projections and sub-queries inline.
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs
trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs
trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/Mappings.hbm.xml
Modified: trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs 2009-11-30 13:28:06 UTC (rev 4876)
+++ trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs 2009-11-30 17:10:42 UTC (rev 4877)
@@ -264,7 +264,7 @@
return this;
}
- QueryOverProjectionBuilder<QueryOver<TRoot,TSubType>, TRoot, TSubType> SelectList
+ public QueryOverProjectionBuilder<QueryOver<TRoot,TSubType>, TRoot, TSubType> SelectList
{
get { return new QueryOverProjectionBuilder<QueryOver<TRoot,TSubType>, TRoot, TSubType>(this, this); }
}
Modified: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs 2009-11-30 13:28:06 UTC (rev 4876)
+++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs 2009-11-30 17:10:42 UTC (rev 4877)
@@ -205,6 +205,66 @@
}
}
+ [Test]
+ public void SubQuery()
+ {
+ using (ISession s = OpenSession())
+ using (ITransaction t = s.BeginTransaction())
+ {
+ s.Save(new Person() { Name = "Name 1", Age = 1 }
+ .AddChild(new Child() { Nickname = "Name 1.1", Age = 1}));
+
+ s.Save(new Person() { Name = "Name 2", Age = 2 }
+ .AddChild(new Child() { Nickname = "Name 2.1", Age = 2})
+ .AddChild(new Child() { Nickname = "Name 2.2", Age = 2}));
+
+ s.Save(new Person() { Name = "Name 3", Age = 3 }
+ .AddChild(new Child() { Nickname = "Name 3.1", Age = 3}));
+
+ t.Commit();
+ }
+
+ using (ISession s = OpenSession())
+ {
+ Person personAlias = null;
+ object childCountAlias = null;
+
+ QueryOver<Child> averageChildAge =
+ QueryOver.Of<Child>()
+ .SelectList
+ .SelectAvg(c => c.Age)
+ .EndSelect;
+
+ QueryOver<Child> childCountQuery =
+ QueryOver.Of<Child>()
+ .Where(c => c.Parent.Id == personAlias.Id)
+ .Select(Projections.RowCount());
+
+ var nameAndChildCount =
+ s.QueryOver<Person>(() => personAlias)
+ .WithSubquery.Where(p => p.Age <= averageChildAge.As<int>())
+ .SelectList
+ .Select(p => p.Name)
+ .SelectSubQuery(childCountQuery).WithAlias(() => childCountAlias)
+ .EndSelect
+ .OrderBy(() => childCountAlias).Desc
+ .List<object[]>()
+ .Select(props => new {
+ Name = (string)props[0],
+ ChildCount = (int)props[1],
+ })
+ .ToList();
+
+ Assert.That(nameAndChildCount.Count, Is.EqualTo(2));
+
+ Assert.That(nameAndChildCount[0].Name, Is.EqualTo("Name 2"));
+ Assert.That(nameAndChildCount[0].ChildCount, Is.EqualTo(2));
+
+ Assert.That(nameAndChildCount[1].Name, Is.EqualTo("Name 1"));
+ Assert.That(nameAndChildCount[1].ChildCount, Is.EqualTo(1));
+ }
+ }
+
}
}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/Mappings.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/Mappings.hbm.xml 2009-11-30 13:28:06 UTC (rev 4876)
+++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/Mappings.hbm.xml 2009-11-30 17:10:42 UTC (rev 4877)
@@ -21,6 +21,7 @@
<generator class="native"/>
</id>
<property name="Nickname" />
+ <property name="Age" />
<many-to-one name="Parent" class="Person" />
</class>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2009-11-30 17:48:54
|
Revision: 4878
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4878&view=rev
Author: fabiomaulo
Date: 2009-11-30 17:48:41 +0000 (Mon, 30 Nov 2009)
Log Message:
-----------
binders refactoring
-pushing down the XML parsing
-removed duplicated code
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/PropertiesBinder.cs
trunk/nhibernate/src/NHibernate/NHibernate.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmJoin.cs
Added: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmJoin.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmJoin.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmJoin.cs 2009-11-30 17:48:41 UTC (rev 4878)
@@ -0,0 +1,42 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace NHibernate.Cfg.MappingSchema
+{
+ public partial class HbmJoin : IEntitySqlsMapping, IPropertiesContainerMapping
+ {
+ #region Implementation of IEntitySqlsMapping
+
+ public HbmLoader SqlLoader
+ {
+ get { return null; }
+ }
+
+ public HbmCustomSQL SqlInsert
+ {
+ get { return sqlinsert; }
+ }
+
+ public HbmCustomSQL SqlUpdate
+ {
+ get { return sqlupdate; }
+ }
+
+ public HbmCustomSQL SqlDelete
+ {
+ get { return sqldelete; }
+ }
+
+ #endregion
+
+ #region Implementation of IPropertiesContainerMapping
+
+ public IEnumerable<IEntityPropertyMapping> Properties
+ {
+ get { return Items != null ? Items.Cast<IEntityPropertyMapping>() : new IEntityPropertyMapping[0]; }
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs 2009-11-30 17:10:42 UTC (rev 4877)
+++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs 2009-11-30 17:48:41 UTC (rev 4878)
@@ -176,117 +176,52 @@
foreach (var hbmJoin in joins)
{
var join = new Join { PersistentClass = persistentClass };
- BindJoin(Serialize(hbmJoin), join, inheritedMetas);
+ BindJoin(hbmJoin, join, inheritedMetas);
persistentClass.AddJoin(join);
}
}
- private void BindJoin(XmlNode node, Join join, IDictionary<string, MetaAttribute> inheritedMetas)
+ private void BindJoin(HbmJoin joinMapping, Join join, IDictionary<string, MetaAttribute> inheritedMetas)
{
PersistentClass persistentClass = join.PersistentClass;
- String path = persistentClass.EntityName;
// TABLENAME
+ string schema = joinMapping.schema ?? mappings.SchemaName;
+ string catalog = joinMapping.catalog ?? mappings.CatalogName;
- XmlAttribute schemaNode = node.Attributes["schema"];
- string schema = schemaNode == null ? mappings.SchemaName : schemaNode.Value;
- XmlAttribute catalogNode = node.Attributes["catalog"];
- string catalog = catalogNode == null ? mappings.CatalogName : catalogNode.Value;
+ string action = "all"; // joinMapping.schemaaction ?? "all";
- XmlAttribute actionNode = node.Attributes["schema-action"];
- string action = actionNode == null ? "all" : actionNode.Value;
-
- string tableName = node.Attributes["table"] != null ? node.Attributes["table"].Value : null;
+ string tableName = joinMapping.table;
Table table = mappings.AddTable(schema, catalog, GetClassTableName(persistentClass, tableName), null, false, action);
join.Table = table;
- XmlAttribute fetchNode = node.Attributes["fetch"];
- if (fetchNode != null)
- join.IsSequentialSelect = "select".Equals(fetchNode.Value);
+ join.IsSequentialSelect = joinMapping.fetch == HbmJoinFetch.Select;
+ join.IsInverse = joinMapping.inverse;
+ join.IsOptional = joinMapping.optional;
- XmlAttribute invNode = node.Attributes["inverse"];
- if (invNode != null)
- join.IsInverse = "true".Equals(invNode.Value);
-
- XmlAttribute nullNode = node.Attributes["optional"];
- if (nullNode != null)
- join.IsOptional = "true".Equals(nullNode.Value);
-
log.InfoFormat("Mapping class join: {0} -> {1}", persistentClass.EntityName, join.Table.Name);
// KEY
- XmlNode keyNode = node.SelectSingleNode(HbmConstants.nsKey, namespaceManager);
SimpleValue key = new DependantValue(table, persistentClass.Identifier);
join.Key = key;
- if (keyNode.Attributes["on-delete"] != null)
- key.IsCascadeDeleteEnabled = "cascade".Equals(keyNode.Attributes["on-delete"].Value);
- BindSimpleValue(keyNode, key, false, persistentClass.EntityName);
+ key.IsCascadeDeleteEnabled = joinMapping.key.ondelete == HbmOndelete.Cascade;
+ BindSimpleValue(Serialize(joinMapping.key), key, false, persistentClass.EntityName);
join.CreatePrimaryKey(dialect);
join.CreateForeignKey();
// PROPERTIES
- //PropertiesFromXML(node, persistentClass, mappings);
- foreach (XmlNode subnode in node.ChildNodes)
- {
- //I am only concerned with elements that are from the nhibernate namespace
- if (subnode.NamespaceURI != MappingSchemaXMLNS)
- continue;
+ new PropertiesBinder(Mappings, persistentClass, namespaceManager, dialect).Bind(joinMapping.Properties, join.Table,
+ inheritedMetas, p => { },
+ join.AddProperty);
- string name = subnode.Name;
- XmlAttribute nameAttribute = subnode.Attributes["name"];
- string propertyName = nameAttribute == null ? null : nameAttribute.Value;
- IValue value = null;
- var collectionBinder = new CollectionBinder(Mappings, namespaceManager, dialect);
- if (collectionBinder.CanCreate(name))
- {
- Mapping.Collection collection = collectionBinder.Create(name, subnode, persistentClass.EntityName, propertyName,
- persistentClass, persistentClass.MappedClass,
- inheritedMetas);
-
- mappings.AddCollection(collection);
- value = collection;
- }
- else
- {
- switch (name)
- {
- case "many-to-one":
- value = new ManyToOne(table);
- BindManyToOne(subnode, (ManyToOne) value, propertyName, true);
- break;
- case "any":
- value = new Any(table);
- BindAny(subnode, (Any) value, true);
- break;
- case "property":
- value = new SimpleValue(table);
- BindSimpleValue(subnode, (SimpleValue) value, true, propertyName);
- break;
- case "component":
- case "dynamic-component":
- string subpath = StringHelper.Qualify(path, propertyName);
- value = new Component(join);
- BindComponent(subnode, (Component) value, join.PersistentClass.MappedClass, join.PersistentClass.ClassName,
- propertyName, subpath, true, inheritedMetas);
- break;
- }
- }
- if (value != null)
- {
- var prop = CreateProperty(value, propertyName, persistentClass.MappedClass.AssemblyQualifiedName, subnode,
- inheritedMetas);
- prop.IsOptional = join.IsOptional;
- join.AddProperty(prop);
- }
- }
-
// CUSTOM SQL
- HandleCustomSQL(node, join);
+ HandleCustomSQL(joinMapping, join);
}
private void HandleCustomSQL(IEntitySqlsMapping sqlsMapping, PersistentClass model)
{
+ // TODO : common interface between PersistentClass & Join for custom SQL
var sqlInsert = sqlsMapping.SqlInsert;
if (sqlInsert != null)
{
@@ -312,27 +247,28 @@
model.LoaderName = sqlsMapping.SqlLoader.queryref;
}
- private void HandleCustomSQL(XmlNode node, Join model)
+ private void HandleCustomSQL(IEntitySqlsMapping sqlsMapping, Join model)
{
- XmlNode element = node.SelectSingleNode(HbmConstants.nsSqlInsert, namespaceManager);
- if (element != null)
+ // TODO : common interface between PersistentClass & Join for custom SQL
+ var sqlInsert = sqlsMapping.SqlInsert;
+ if (sqlInsert != null)
{
- bool callable = IsCallable(element);
- model.SetCustomSQLInsert(element.InnerText.Trim(), callable, GetResultCheckStyle(element, callable));
+ bool callable = sqlInsert.callableSpecified && sqlInsert.callable;
+ model.SetCustomSQLInsert(sqlInsert.Text.LinesToString(), callable, GetResultCheckStyle(sqlInsert));
}
- element = node.SelectSingleNode(HbmConstants.nsSqlDelete, namespaceManager);
- if (element != null)
+ var sqlDelete = sqlsMapping.SqlDelete;
+ if (sqlDelete != null)
{
- bool callable = IsCallable(element);
- model.SetCustomSQLDelete(element.InnerText.Trim(), callable, GetResultCheckStyle(element, callable));
+ bool callable = sqlDelete.callableSpecified && sqlDelete.callable;
+ model.SetCustomSQLDelete(sqlDelete.Text.LinesToString(), callable, GetResultCheckStyle(sqlDelete));
}
- element = node.SelectSingleNode(HbmConstants.nsSqlUpdate, namespaceManager);
- if (element != null)
+ var sqlUpdate = sqlsMapping.SqlUpdate;
+ if (sqlUpdate != null)
{
- bool callable = IsCallable(element);
- model.SetCustomSQLUpdate(element.InnerText.Trim(), callable, GetResultCheckStyle(element, callable));
+ bool callable = sqlUpdate.callableSpecified && sqlUpdate.callable;
+ model.SetCustomSQLUpdate(sqlUpdate.Text.LinesToString(), callable, GetResultCheckStyle(sqlUpdate));
}
}
Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/PropertiesBinder.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/PropertiesBinder.cs 2009-11-30 17:10:42 UTC (rev 4877)
+++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/PropertiesBinder.cs 2009-11-30 17:48:41 UTC (rev 4878)
@@ -20,18 +20,33 @@
public void Bind(IEnumerable<IEntityPropertyMapping> properties, IDictionary<string, MetaAttribute> inheritedMetas)
{
- Bind(properties, inheritedMetas, null);
+ Bind(properties, inheritedMetas, p => { });
}
public void Bind(IEnumerable<IEntityPropertyMapping> properties, IDictionary<string, MetaAttribute> inheritedMetas, Action<Property> modifier)
{
- Action<Property> action = modifier ?? (p => { });
+ Bind(properties, model.Table, inheritedMetas, modifier, p => model.AddProperty(p));
+ }
+
+ public void Bind(IEnumerable<IEntityPropertyMapping> properties, Table table, IDictionary<string, MetaAttribute> inheritedMetas, Action<Property> modifier, Action<Property> addToModelAction)
+ {
+ if (table == null)
+ {
+ throw new ArgumentNullException("table");
+ }
+ if (modifier == null)
+ {
+ throw new ArgumentNullException("modifier");
+ }
+ if (addToModelAction == null)
+ {
+ throw new ArgumentNullException("addToModelAction");
+ }
string entityName = model.EntityName;
- Table table = model.Table;
foreach (var entityPropertyMapping in properties)
{
- Property property= null;
+ Property property = null;
string propertyName = entityPropertyMapping.Name;
@@ -106,9 +121,9 @@
BindAnyProperty(anyMapping, property);
}
- if(property != null)
+ if (property != null)
{
- action(property);
+ modifier(property);
if (log.IsDebugEnabled)
{
string msg = "Mapped property: " + property.Name;
@@ -119,9 +134,9 @@
msg += ", type: " + property.Type.Name;
log.Debug(msg);
}
- model.AddProperty(property);
+ addToModelAction(property);
}
- }
+ }
}
private void BindValueProperty(HbmProperty propertyMapping, Property property)
Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-11-30 17:10:42 UTC (rev 4877)
+++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-11-30 17:48:41 UTC (rev 4878)
@@ -502,6 +502,7 @@
<Compile Include="Cfg\MappingSchema\HbmDynamicComponent.cs" />
<Compile Include="Cfg\MappingSchema\HbmExtensions.cs" />
<Compile Include="Cfg\MappingSchema\HbmIdbag.cs" />
+ <Compile Include="Cfg\MappingSchema\HbmJoin.cs" />
<Compile Include="Cfg\MappingSchema\HbmJoinedSubclass.cs" />
<Compile Include="Cfg\MappingSchema\HbmList.cs" />
<Compile Include="Cfg\MappingSchema\HbmManyToOne.cs" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2009-11-30 20:31:34
|
Revision: 4879
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4879&view=rev
Author: fabiomaulo
Date: 2009-11-30 20:31:06 +0000 (Mon, 30 Nov 2009)
Log Message:
-----------
binders refactoring
-removed duplicated code
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs
trunk/nhibernate/src/NHibernate/Mapping/Join.cs
trunk/nhibernate/src/NHibernate/Mapping/PersistentClass.cs
trunk/nhibernate/src/NHibernate/NHibernate.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate/Mapping/ISqlCustomizable.cs
Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs 2009-11-30 17:48:41 UTC (rev 4878)
+++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs 2009-11-30 20:31:06 UTC (rev 4879)
@@ -115,6 +115,8 @@
// CUSTOM SQL
HandleCustomSQL(classMapping, model);
+ if (classMapping.SqlLoader != null)
+ model.LoaderName = classMapping.SqlLoader.queryref;
foreach (var synchronize in classMapping.Synchronize)
{
@@ -219,9 +221,8 @@
HandleCustomSQL(joinMapping, join);
}
- private void HandleCustomSQL(IEntitySqlsMapping sqlsMapping, PersistentClass model)
+ private void HandleCustomSQL(IEntitySqlsMapping sqlsMapping, ISqlCustomizable model)
{
- // TODO : common interface between PersistentClass & Join for custom SQL
var sqlInsert = sqlsMapping.SqlInsert;
if (sqlInsert != null)
{
@@ -242,36 +243,8 @@
bool callable = sqlUpdate.callableSpecified && sqlUpdate.callable;
model.SetCustomSQLUpdate(sqlUpdate.Text.LinesToString(), callable, GetResultCheckStyle(sqlUpdate));
}
-
- if (sqlsMapping.SqlLoader != null)
- model.LoaderName = sqlsMapping.SqlLoader.queryref;
}
- private void HandleCustomSQL(IEntitySqlsMapping sqlsMapping, Join model)
- {
- // TODO : common interface between PersistentClass & Join for custom SQL
- var sqlInsert = sqlsMapping.SqlInsert;
- if (sqlInsert != null)
- {
- bool callable = sqlInsert.callableSpecified && sqlInsert.callable;
- model.SetCustomSQLInsert(sqlInsert.Text.LinesToString(), callable, GetResultCheckStyle(sqlInsert));
- }
-
- var sqlDelete = sqlsMapping.SqlDelete;
- if (sqlDelete != null)
- {
- bool callable = sqlDelete.callableSpecified && sqlDelete.callable;
- model.SetCustomSQLDelete(sqlDelete.Text.LinesToString(), callable, GetResultCheckStyle(sqlDelete));
- }
-
- var sqlUpdate = sqlsMapping.SqlUpdate;
- if (sqlUpdate != null)
- {
- bool callable = sqlUpdate.callableSpecified && sqlUpdate.callable;
- model.SetCustomSQLUpdate(sqlUpdate.Text.LinesToString(), callable, GetResultCheckStyle(sqlUpdate));
- }
- }
-
protected PersistentClass GetSuperclass(XmlNode subnode)
{
XmlAttribute extendsAttr = subnode.Attributes["extends"];
Added: trunk/nhibernate/src/NHibernate/Mapping/ISqlCustomizable.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Mapping/ISqlCustomizable.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Mapping/ISqlCustomizable.cs 2009-11-30 20:31:06 UTC (rev 4879)
@@ -0,0 +1,11 @@
+using NHibernate.Engine;
+
+namespace NHibernate.Mapping
+{
+ public interface ISqlCustomizable
+ {
+ void SetCustomSQLInsert(string sql, bool callable, ExecuteUpdateResultCheckStyle checkStyle);
+ void SetCustomSQLUpdate(string sql, bool callable, ExecuteUpdateResultCheckStyle checkStyle);
+ void SetCustomSQLDelete(string sql, bool callable, ExecuteUpdateResultCheckStyle checkStyle);
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Mapping/Join.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Mapping/Join.cs 2009-11-30 17:48:41 UTC (rev 4878)
+++ trunk/nhibernate/src/NHibernate/Mapping/Join.cs 2009-11-30 20:31:06 UTC (rev 4879)
@@ -7,7 +7,7 @@
namespace NHibernate.Mapping
{
[Serializable]
- public class Join
+ public class Join : ISqlCustomizable
{
private static readonly Alias PK_ALIAS = new Alias(15, "PK");
Modified: trunk/nhibernate/src/NHibernate/Mapping/PersistentClass.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Mapping/PersistentClass.cs 2009-11-30 17:48:41 UTC (rev 4878)
+++ trunk/nhibernate/src/NHibernate/Mapping/PersistentClass.cs 2009-11-30 20:31:06 UTC (rev 4879)
@@ -14,7 +14,7 @@
/// <c><joined-subclass></c>.
/// </summary>
[Serializable]
- public abstract class PersistentClass : IFilterable, IMetaAttributable
+ public abstract class PersistentClass : IFilterable, IMetaAttributable, ISqlCustomizable
{
private static readonly Alias PKAlias = new Alias(15, "PK");
Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-11-30 17:48:41 UTC (rev 4878)
+++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-11-30 20:31:06 UTC (rev 4879)
@@ -669,6 +669,7 @@
<Compile Include="Loader\Criteria\EntityCriteriaInfoProvider.cs" />
<Compile Include="Loader\Criteria\ICriteriaInfoProvider.cs" />
<Compile Include="Loader\Criteria\ScalarCollectionCriteriaInfoProvider.cs" />
+ <Compile Include="Mapping\ISqlCustomizable.cs" />
<Compile Include="Param\AbstractExplicitParameterSpecification.cs" />
<Compile Include="Param\AggregatedIndexCollectionSelectorParameterSpecifications.cs" />
<Compile Include="Param\CollectionFilterKeyParameterSpecification.cs" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2009-12-01 00:19:10
|
Revision: 4880
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4880&view=rev
Author: fabiomaulo
Date: 2009-12-01 00:18:30 +0000 (Tue, 01 Dec 2009)
Log Message:
-----------
Preparing other binders refactoring
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmAny.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmManyToOne.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmOneToOne.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmProperty.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmVersion.cs
trunk/nhibernate/src/NHibernate/NHibernate.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmCollectionId.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmDiscriminator.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmElement.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmId.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmIndex.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmIndexManyToAny.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmIndexManyToMany.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmKey.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmKeyManyToOne.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmKeyProperty.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmListIndex.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmManyToAny.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmManyToMany.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmMapKey.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmMapKeyManyToMany.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/IColumnsMapping.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/IFormulasMapping.cs
Modified: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmAny.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmAny.cs 2009-11-30 20:31:06 UTC (rev 4879)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmAny.cs 2009-12-01 00:18:30 UTC (rev 4880)
@@ -1,8 +1,9 @@
using System;
+using System.Collections.Generic;
namespace NHibernate.Cfg.MappingSchema
{
- public partial class HbmAny : AbstractDecoratable, IEntityPropertyMapping
+ public partial class HbmAny : AbstractDecoratable, IEntityPropertyMapping, IColumnsMapping
{
#region Implementation of IEntityPropertyMapping
@@ -31,5 +32,30 @@
}
#endregion
+
+ #region Implementation of IColumnsMapping
+
+ public IEnumerable<HbmColumn> Columns
+ {
+ get { return column ?? AsColumns(); }
+ }
+
+ #endregion
+
+ private IEnumerable<HbmColumn> AsColumns()
+ {
+ if (string.IsNullOrEmpty(column1))
+ {
+ yield break;
+ }
+ else
+ {
+ yield return new HbmColumn
+ {
+ name = column1,
+ index = index
+ };
+ }
+ }
}
}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmCollectionId.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmCollectionId.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmCollectionId.cs 2009-12-01 00:18:30 UTC (rev 4880)
@@ -0,0 +1,32 @@
+using System.Collections.Generic;
+
+namespace NHibernate.Cfg.MappingSchema
+{
+ public partial class HbmCollectionId: IColumnsMapping
+ {
+ #region Implementation of IColumnsMapping
+
+ public IEnumerable<HbmColumn> Columns
+ {
+ get { return column ?? AsColumns(); }
+ }
+
+ #endregion
+
+ private IEnumerable<HbmColumn> AsColumns()
+ {
+ if(string.IsNullOrEmpty(column1))
+ {
+ yield break;
+ }
+ else
+ {
+ yield return new HbmColumn
+ {
+ name = column1,
+ length = length,
+ };
+ }
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmDiscriminator.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmDiscriminator.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmDiscriminator.cs 2009-12-01 00:18:30 UTC (rev 4880)
@@ -0,0 +1,58 @@
+using System;
+using System.Collections.Generic;
+
+namespace NHibernate.Cfg.MappingSchema
+{
+ public partial class HbmDiscriminator: IColumnsMapping, IFormulasMapping
+ {
+ #region Implementation of IColumnsMapping
+
+ public IEnumerable<HbmColumn> Columns
+ {
+ get
+ {
+ if(Item as HbmColumn != null)
+ {
+ yield return (HbmColumn)Item;
+ }
+ else if (string.IsNullOrEmpty(column))
+ {
+ yield break;
+ }
+ else
+ {
+ yield return new HbmColumn
+ {
+ name = column,
+ length = length,
+ };
+ }
+ }
+ }
+
+ #endregion
+
+ #region Implementation of IFormulasMapping
+
+ public IEnumerable<HbmFormula> Formulas
+ {
+ get
+ {
+ if (Item as HbmFormula != null)
+ {
+ yield return (HbmFormula) Item;
+ }
+ else if (string.IsNullOrEmpty(formula))
+ {
+ yield break;
+ }
+ else
+ {
+ yield return new HbmFormula {Text = new[] {formula}};
+ }
+ }
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmElement.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmElement.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmElement.cs 2009-12-01 00:18:30 UTC (rev 4880)
@@ -0,0 +1,60 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace NHibernate.Cfg.MappingSchema
+{
+ public partial class HbmElement: IColumnsMapping, IFormulasMapping
+ {
+ #region Implementation of IColumnsMapping
+
+ public IEnumerable<HbmColumn> Columns
+ {
+ get { return Items != null ? Items.OfType<HbmColumn>() : AsColumns(); }
+ }
+
+ #endregion
+
+ private IEnumerable<HbmColumn> AsColumns()
+ {
+ if (string.IsNullOrEmpty(column))
+ {
+ yield break;
+ }
+ else
+ {
+ yield return new HbmColumn
+ {
+ name = column,
+ length = length,
+ scale = scale,
+ precision = precision,
+ notnull = notnull,
+ unique = unique,
+ uniqueSpecified = true,
+ };
+ }
+ }
+
+ #region Implementation of IFormulasMapping
+
+ public IEnumerable<HbmFormula> Formulas
+ {
+ get { return Items != null ? Items.OfType<HbmFormula>() : AsFormulas(); }
+ }
+
+ private IEnumerable<HbmFormula> AsFormulas()
+ {
+ if (string.IsNullOrEmpty(formula))
+ {
+ yield break;
+ }
+ else
+ {
+ yield return new HbmFormula { Text = new[] { formula } };
+ }
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmId.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmId.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmId.cs 2009-12-01 00:18:30 UTC (rev 4880)
@@ -0,0 +1,32 @@
+using System.Collections.Generic;
+
+namespace NHibernate.Cfg.MappingSchema
+{
+ public partial class HbmId: IColumnsMapping
+ {
+ #region Implementation of IColumnsMapping
+
+ public IEnumerable<HbmColumn> Columns
+ {
+ get { return column ?? AsColumns(); }
+ }
+
+ #endregion
+
+ private IEnumerable<HbmColumn> AsColumns()
+ {
+ if (string.IsNullOrEmpty(column1))
+ {
+ yield break;
+ }
+ else
+ {
+ yield return new HbmColumn
+ {
+ name = column1,
+ length = length,
+ };
+ }
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmIndex.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmIndex.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmIndex.cs 2009-12-01 00:18:30 UTC (rev 4880)
@@ -0,0 +1,32 @@
+using System.Collections.Generic;
+
+namespace NHibernate.Cfg.MappingSchema
+{
+ public partial class HbmIndex: IColumnsMapping
+ {
+ #region Implementation of IColumnsMapping
+
+ public IEnumerable<HbmColumn> Columns
+ {
+ get { return column ?? AsColumns(); }
+ }
+
+ #endregion
+
+ private IEnumerable<HbmColumn> AsColumns()
+ {
+ if (string.IsNullOrEmpty(column1))
+ {
+ yield break;
+ }
+ else
+ {
+ yield return new HbmColumn
+ {
+ name = column1,
+ length = length,
+ };
+ }
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmIndexManyToAny.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmIndexManyToAny.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmIndexManyToAny.cs 2009-12-01 00:18:30 UTC (rev 4880)
@@ -0,0 +1,31 @@
+using System.Collections.Generic;
+
+namespace NHibernate.Cfg.MappingSchema
+{
+ public partial class HbmIndexManyToAny: IColumnsMapping
+ {
+ #region Implementation of IColumnsMapping
+
+ public IEnumerable<HbmColumn> Columns
+ {
+ get { return column ?? AsColumns(); }
+ }
+
+ #endregion
+
+ private IEnumerable<HbmColumn> AsColumns()
+ {
+ if (string.IsNullOrEmpty(column1))
+ {
+ yield break;
+ }
+ else
+ {
+ yield return new HbmColumn
+ {
+ name = column1,
+ };
+ }
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmIndexManyToMany.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmIndexManyToMany.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmIndexManyToMany.cs 2009-12-01 00:18:30 UTC (rev 4880)
@@ -0,0 +1,31 @@
+using System.Collections.Generic;
+
+namespace NHibernate.Cfg.MappingSchema
+{
+ public partial class HbmIndexManyToMany: IColumnsMapping
+ {
+ #region Implementation of IColumnsMapping
+
+ public IEnumerable<HbmColumn> Columns
+ {
+ get { return column ?? AsColumns(); }
+ }
+
+ #endregion
+
+ private IEnumerable<HbmColumn> AsColumns()
+ {
+ if (string.IsNullOrEmpty(column1))
+ {
+ yield break;
+ }
+ else
+ {
+ yield return new HbmColumn
+ {
+ name = column1,
+ };
+ }
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmKey.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmKey.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmKey.cs 2009-12-01 00:18:30 UTC (rev 4880)
@@ -0,0 +1,35 @@
+using System.Collections.Generic;
+
+namespace NHibernate.Cfg.MappingSchema
+{
+ public partial class HbmKey: IColumnsMapping
+ {
+ #region Implementation of IColumnsMapping
+
+ public IEnumerable<HbmColumn> Columns
+ {
+ get { return column ?? AsColumns(); }
+ }
+
+ #endregion
+
+ private IEnumerable<HbmColumn> AsColumns()
+ {
+ if (string.IsNullOrEmpty(column1))
+ {
+ yield break;
+ }
+ else
+ {
+ yield return new HbmColumn
+ {
+ name = column1,
+ notnull = notnull,
+ notnullSpecified = notnullSpecified,
+ unique = unique,
+ uniqueSpecified = uniqueSpecified,
+ };
+ }
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmKeyManyToOne.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmKeyManyToOne.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmKeyManyToOne.cs 2009-12-01 00:18:30 UTC (rev 4880)
@@ -0,0 +1,32 @@
+using System.Collections.Generic;
+
+namespace NHibernate.Cfg.MappingSchema
+{
+ public partial class HbmKeyManyToOne: IColumnsMapping
+ {
+
+ #region Implementation of IColumnsMapping
+
+ public IEnumerable<HbmColumn> Columns
+ {
+ get { return column ?? AsColumns(); }
+ }
+
+ #endregion
+
+ private IEnumerable<HbmColumn> AsColumns()
+ {
+ if (string.IsNullOrEmpty(column1))
+ {
+ yield break;
+ }
+ else
+ {
+ yield return new HbmColumn
+ {
+ name = column1,
+ };
+ }
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmKeyProperty.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmKeyProperty.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmKeyProperty.cs 2009-12-01 00:18:30 UTC (rev 4880)
@@ -0,0 +1,33 @@
+using System.Collections.Generic;
+
+namespace NHibernate.Cfg.MappingSchema
+{
+ public partial class HbmKeyProperty: IColumnsMapping
+ {
+
+ #region Implementation of IColumnsMapping
+
+ public IEnumerable<HbmColumn> Columns
+ {
+ get { return column ?? AsColumns(); }
+ }
+
+ #endregion
+
+ private IEnumerable<HbmColumn> AsColumns()
+ {
+ if (string.IsNullOrEmpty(column1))
+ {
+ yield break;
+ }
+ else
+ {
+ yield return new HbmColumn
+ {
+ name = column1,
+ length = length,
+ };
+ }
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmListIndex.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmListIndex.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmListIndex.cs 2009-12-01 00:18:30 UTC (rev 4880)
@@ -0,0 +1,29 @@
+using System.Collections.Generic;
+
+namespace NHibernate.Cfg.MappingSchema
+{
+ public partial class HbmListIndex: IColumnsMapping
+ {
+ public IEnumerable<HbmColumn> Columns
+ {
+ get
+ {
+ if (column != null)
+ {
+ yield return column;
+ }
+ else if (string.IsNullOrEmpty(column1))
+ {
+ yield break;
+ }
+ else
+ {
+ yield return new HbmColumn
+ {
+ name = column1,
+ };
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmManyToAny.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmManyToAny.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmManyToAny.cs 2009-12-01 00:18:30 UTC (rev 4880)
@@ -0,0 +1,32 @@
+using System.Collections.Generic;
+
+namespace NHibernate.Cfg.MappingSchema
+{
+ public partial class HbmManyToAny: IColumnsMapping
+ {
+
+ #region Implementation of IColumnsMapping
+
+ public IEnumerable<HbmColumn> Columns
+ {
+ get { return column ?? AsColumns(); }
+ }
+
+ #endregion
+
+ private IEnumerable<HbmColumn> AsColumns()
+ {
+ if (string.IsNullOrEmpty(column1))
+ {
+ yield break;
+ }
+ else
+ {
+ yield return new HbmColumn
+ {
+ name = column1,
+ };
+ }
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmManyToMany.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmManyToMany.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmManyToMany.cs 2009-12-01 00:18:30 UTC (rev 4880)
@@ -0,0 +1,33 @@
+using System.Collections.Generic;
+using System.Linq;
+
+namespace NHibernate.Cfg.MappingSchema
+{
+ public partial class HbmManyToMany: IColumnsMapping
+ {
+
+ #region Implementation of IColumnsMapping
+
+ public IEnumerable<HbmColumn> Columns
+ {
+ get { return Items != null ? Items.OfType<HbmColumn>() : AsColumns(); }
+ }
+
+ #endregion
+
+ private IEnumerable<HbmColumn> AsColumns()
+ {
+ if (string.IsNullOrEmpty(column))
+ {
+ yield break;
+ }
+ else
+ {
+ yield return new HbmColumn
+ {
+ name = column,
+ };
+ }
+ }
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmManyToOne.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmManyToOne.cs 2009-11-30 20:31:06 UTC (rev 4879)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmManyToOne.cs 2009-12-01 00:18:30 UTC (rev 4880)
@@ -1,8 +1,10 @@
using System;
+using System.Collections.Generic;
+using System.Linq;
namespace NHibernate.Cfg.MappingSchema
{
- public partial class HbmManyToOne : AbstractDecoratable, IEntityPropertyMapping
+ public partial class HbmManyToOne : AbstractDecoratable, IEntityPropertyMapping, IColumnsMapping, IFormulasMapping
{
#region Implementation of IEntityPropertyMapping
@@ -32,5 +34,55 @@
#endregion
+ #region Implementation of IColumnsMapping
+
+ public IEnumerable<HbmColumn> Columns
+ {
+ get { return Items != null ? Items.OfType<HbmColumn>() : AsColumns(); }
+ }
+
+ #endregion
+
+ private IEnumerable<HbmColumn> AsColumns()
+ {
+ if (string.IsNullOrEmpty(column))
+ {
+ yield break;
+ }
+ else
+ {
+ yield return new HbmColumn
+ {
+ name = column,
+ notnull = notnull,
+ notnullSpecified = notnullSpecified,
+ unique = unique,
+ uniqueSpecified = true,
+ uniquekey = uniquekey,
+ index = index
+ };
+ }
+ }
+
+ #region Implementation of IFormulasMapping
+
+ public IEnumerable<HbmFormula> Formulas
+ {
+ get { return Items != null ? Items.OfType<HbmFormula>() : AsFormulas(); }
+ }
+
+ private IEnumerable<HbmFormula> AsFormulas()
+ {
+ if (string.IsNullOrEmpty(formula))
+ {
+ yield break;
+ }
+ else
+ {
+ yield return new HbmFormula { Text = new[] { formula } };
+ }
+ }
+
+ #endregion
}
}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmMapKey.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmMapKey.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmMapKey.cs 2009-12-01 00:18:30 UTC (rev 4880)
@@ -0,0 +1,55 @@
+using System.Collections.Generic;
+using System.Linq;
+
+namespace NHibernate.Cfg.MappingSchema
+{
+ public partial class HbmMapKey: IColumnsMapping
+ {
+
+ #region Implementation of IColumnsMapping
+
+ public IEnumerable<HbmColumn> Columns
+ {
+ get { return Items != null ? Items.OfType<HbmColumn>() : AsColumns(); }
+ }
+
+ #endregion
+
+ private IEnumerable<HbmColumn> AsColumns()
+ {
+ if (string.IsNullOrEmpty(column))
+ {
+ yield break;
+ }
+ else
+ {
+ yield return new HbmColumn
+ {
+ name = column,
+ length = length,
+ };
+ }
+ }
+
+ #region Implementation of IFormulasMapping
+
+ public IEnumerable<HbmFormula> Formulas
+ {
+ get { return Items != null ? Items.OfType<HbmFormula>() : AsFormulas(); }
+ }
+
+ private IEnumerable<HbmFormula> AsFormulas()
+ {
+ if (string.IsNullOrEmpty(formula))
+ {
+ yield break;
+ }
+ else
+ {
+ yield return new HbmFormula { Text = new[] { formula } };
+ }
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmMapKeyManyToMany.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmMapKeyManyToMany.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmMapKeyManyToMany.cs 2009-12-01 00:18:30 UTC (rev 4880)
@@ -0,0 +1,54 @@
+using System.Collections.Generic;
+using System.Linq;
+
+namespace NHibernate.Cfg.MappingSchema
+{
+ public partial class HbmMapKeyManyToMany: IColumnsMapping, IFormulasMapping
+ {
+
+ #region Implementation of IColumnsMapping
+
+ public IEnumerable<HbmColumn> Columns
+ {
+ get { return Items != null ? Items.OfType<HbmColumn>() : AsColumns(); }
+ }
+
+ #endregion
+
+ private IEnumerable<HbmColumn> AsColumns()
+ {
+ if (string.IsNullOrEmpty(column))
+ {
+ yield break;
+ }
+ else
+ {
+ yield return new HbmColumn
+ {
+ name = column,
+ };
+ }
+ }
+
+ #region Implementation of IFormulasMapping
+
+ public IEnumerable<HbmFormula> Formulas
+ {
+ get { return Items != null ? Items.OfType<HbmFormula>() : AsFormulas(); }
+ }
+
+ private IEnumerable<HbmFormula> AsFormulas()
+ {
+ if (string.IsNullOrEmpty(formula))
+ {
+ yield break;
+ }
+ else
+ {
+ yield return new HbmFormula { Text = new[] { formula } };
+ }
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmOneToOne.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmOneToOne.cs 2009-11-30 20:31:06 UTC (rev 4879)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmOneToOne.cs 2009-12-01 00:18:30 UTC (rev 4880)
@@ -1,6 +1,8 @@
+using System.Collections.Generic;
+
namespace NHibernate.Cfg.MappingSchema
{
- public partial class HbmOneToOne : AbstractDecoratable, IEntityPropertyMapping
+ public partial class HbmOneToOne : AbstractDecoratable, IEntityPropertyMapping, IFormulasMapping
{
#region Implementation of IEntityPropertyMapping
@@ -30,5 +32,26 @@
#endregion
+ #region Implementation of IFormulasMapping
+
+ public IEnumerable<HbmFormula> Formulas
+ {
+ get { return formula ?? AsFormulas(); }
+ }
+
+ private IEnumerable<HbmFormula> AsFormulas()
+ {
+ if (string.IsNullOrEmpty(formula1))
+ {
+ yield break;
+ }
+ else
+ {
+ yield return new HbmFormula { Text = new[] { formula1 } };
+ }
+ }
+
+ #endregion
+
}
}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmProperty.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmProperty.cs 2009-11-30 20:31:06 UTC (rev 4879)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmProperty.cs 2009-12-01 00:18:30 UTC (rev 4880)
@@ -1,6 +1,10 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
namespace NHibernate.Cfg.MappingSchema
{
- public partial class HbmProperty : AbstractDecoratable, IEntityPropertyMapping
+ public partial class HbmProperty : AbstractDecoratable, IEntityPropertyMapping, IColumnsMapping, IFormulasMapping
{
#region Implementation of IEntityPropertyMapping
@@ -29,5 +33,59 @@
}
#endregion
+
+ #region Implementation of IColumnsMapping
+
+ public IEnumerable<HbmColumn> Columns
+ {
+ get { return Items != null ? Items.OfType<HbmColumn>() : AsColumns(); }
+ }
+
+ #endregion
+
+ private IEnumerable<HbmColumn> AsColumns()
+ {
+ if(string.IsNullOrEmpty(column))
+ {
+ yield break;
+ }
+ else
+ {
+ yield return new HbmColumn
+ {
+ name = column,
+ length = length,
+ scale = scale,
+ precision = precision,
+ notnull = notnull,
+ notnullSpecified = notnullSpecified,
+ unique = unique,
+ uniqueSpecified = true,
+ uniquekey = uniquekey,
+ index = index
+ };
+ }
+ }
+
+ #region Implementation of IFormulasMapping
+
+ public IEnumerable<HbmFormula> Formulas
+ {
+ get { return Items != null ? Items.OfType<HbmFormula>() : AsFormulas(); }
+ }
+
+ private IEnumerable<HbmFormula> AsFormulas()
+ {
+ if (string.IsNullOrEmpty(formula))
+ {
+ yield break;
+ }
+ else
+ {
+ yield return new HbmFormula { Text = new[] { formula } };
+ }
+ }
+
+ #endregion
}
}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmVersion.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmVersion.cs 2009-11-30 20:31:06 UTC (rev 4879)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmVersion.cs 2009-12-01 00:18:30 UTC (rev 4880)
@@ -1,10 +1,36 @@
+using System.Collections.Generic;
+
namespace NHibernate.Cfg.MappingSchema
{
- partial class HbmVersion : AbstractDecoratable
+ partial class HbmVersion : AbstractDecoratable, IColumnsMapping
{
protected override HbmMeta[] Metadatas
{
get { return meta ?? new HbmMeta[0]; }
}
+
+ #region Implementation of IColumnsMapping
+
+ public IEnumerable<HbmColumn> Columns
+ {
+ get { return column ?? AsColumns(); }
+ }
+
+ #endregion
+
+ private IEnumerable<HbmColumn> AsColumns()
+ {
+ if (string.IsNullOrEmpty(column1))
+ {
+ yield break;
+ }
+ else
+ {
+ yield return new HbmColumn
+ {
+ name = column1,
+ };
+ }
+ }
}
}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/IColumnsMapping.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/IColumnsMapping.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/IColumnsMapping.cs 2009-12-01 00:18:30 UTC (rev 4880)
@@ -0,0 +1,12 @@
+using System.Collections.Generic;
+
+namespace NHibernate.Cfg.MappingSchema
+{
+ /// <summary>
+ /// Implemented by any mapping elemes supports simple and/or multicolumn mapping.
+ /// </summary>
+ public interface IColumnsMapping
+ {
+ IEnumerable<HbmColumn> Columns { get; }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/IFormulasMapping.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/IFormulasMapping.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/IFormulasMapping.cs 2009-12-01 00:18:30 UTC (rev 4880)
@@ -0,0 +1,9 @@
+using System.Collections.Generic;
+
+namespace NHibernate.Cfg.MappingSchema
+{
+ public interface IFormulasMapping
+ {
+ IEnumerable<HbmFormula> Formulas { get; }
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-11-30 20:31:06 UTC (rev 4879)
+++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-12-01 00:18:30 UTC (rev 4880)
@@ -497,16 +497,31 @@
<Compile Include="Cfg\MappingSchema\HbmAny.cs" />
<Compile Include="Cfg\MappingSchema\HbmArray.cs" />
<Compile Include="Cfg\MappingSchema\HbmBag.cs" />
+ <Compile Include="Cfg\MappingSchema\HbmCollectionId.cs" />
<Compile Include="Cfg\MappingSchema\HbmComponent.cs" />
<Compile Include="Cfg\MappingSchema\HbmDefinition.cs" />
+ <Compile Include="Cfg\MappingSchema\HbmDiscriminator.cs" />
<Compile Include="Cfg\MappingSchema\HbmDynamicComponent.cs" />
+ <Compile Include="Cfg\MappingSchema\HbmElement.cs" />
<Compile Include="Cfg\MappingSchema\HbmExtensions.cs" />
+ <Compile Include="Cfg\MappingSchema\HbmId.cs" />
<Compile Include="Cfg\MappingSchema\HbmIdbag.cs" />
+ <Compile Include="Cfg\MappingSchema\HbmIndex.cs" />
+ <Compile Include="Cfg\MappingSchema\HbmIndexManyToAny.cs" />
+ <Compile Include="Cfg\MappingSchema\HbmIndexManyToMany.cs" />
<Compile Include="Cfg\MappingSchema\HbmJoin.cs" />
<Compile Include="Cfg\MappingSchema\HbmJoinedSubclass.cs" />
+ <Compile Include="Cfg\MappingSchema\HbmKey.cs" />
+ <Compile Include="Cfg\MappingSchema\HbmKeyManyToOne.cs" />
+ <Compile Include="Cfg\MappingSchema\HbmKeyProperty.cs" />
<Compile Include="Cfg\MappingSchema\HbmList.cs" />
+ <Compile Include="Cfg\MappingSchema\HbmListIndex.cs" />
+ <Compile Include="Cfg\MappingSchema\HbmManyToAny.cs" />
+ <Compile Include="Cfg\MappingSchema\HbmManyToMany.cs" />
<Compile Include="Cfg\MappingSchema\HbmManyToOne.cs" />
<Compile Include="Cfg\MappingSchema\HbmMap.cs" />
+ <Compile Include="Cfg\MappingSchema\HbmMapKey.cs" />
+ <Compile Include="Cfg\MappingSchema\HbmMapKeyManyToMany.cs" />
<Compile Include="Cfg\MappingSchema\HbmNaturalId.cs" />
<Compile Include="Cfg\MappingSchema\HbmOneToOne.cs" />
<Compile Include="Cfg\MappingSchema\HbmPrimitiveArray.cs" />
@@ -515,10 +530,12 @@
<Compile Include="Cfg\MappingSchema\HbmSubclass.cs" />
<Compile Include="Cfg\MappingSchema\HbmUnionSubclass.cs" />
<Compile Include="Cfg\MappingSchema\ICollectionPropertyMapping.cs" />
+ <Compile Include="Cfg\MappingSchema\IColumnsMapping.cs" />
<Compile Include="Cfg\MappingSchema\IEntityDiscriminableMapping.cs" />
<Compile Include="Cfg\MappingSchema\IEntityMapping.cs" />
<Compile Include="Cfg\MappingSchema\IEntityPropertyMapping.cs" />
<Compile Include="Cfg\MappingSchema\IEntitySqlsMapping.cs" />
+ <Compile Include="Cfg\MappingSchema\IFormulasMapping.cs" />
<Compile Include="Cfg\MappingSchema\IPropertiesContainerMapping.cs" />
<Compile Include="Cfg\MappingSchema\IReferencePropertyMapping.cs" />
<Compile Include="Cfg\SchemaAutoAction.cs" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2009-12-01 14:26:42
|
Revision: 4881
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4881&view=rev
Author: fabiomaulo
Date: 2009-12-01 14:26:29 +0000 (Tue, 01 Dec 2009)
Log Message:
-----------
binders refactoring
-ColumnsBinder on the road
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmId.cs
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassCompositeIdBinder.cs
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassIdBinder.cs
trunk/nhibernate/src/NHibernate/NHibernate.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ColumnsBinder.cs
Modified: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmId.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmId.cs 2009-12-01 00:18:30 UTC (rev 4880)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmId.cs 2009-12-01 14:26:29 UTC (rev 4881)
@@ -1,3 +1,4 @@
+using System;
using System.Collections.Generic;
namespace NHibernate.Cfg.MappingSchema
@@ -2,3 +3,3 @@
{
- public partial class HbmId: IColumnsMapping
+ public partial class HbmId: AbstractDecoratable, IColumnsMapping
{
@@ -28,5 +29,14 @@
};
}
}
+
+ #region Overrides of AbstractDecoratable
+
+ protected override HbmMeta[] Metadatas
+ {
+ get { return meta ?? new HbmMeta[0]; }
+ }
+
+ #endregion
}
}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassCompositeIdBinder.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassCompositeIdBinder.cs 2009-12-01 00:18:30 UTC (rev 4880)
+++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassCompositeIdBinder.cs 2009-12-01 14:26:29 UTC (rev 4881)
@@ -7,16 +7,15 @@
{
public class ClassCompositeIdBinder : ClassBinder
{
- public ClassCompositeIdBinder(ClassBinder parent)
- : base(parent)
- {
- }
-
private Component compositeId;
+ public ClassCompositeIdBinder(ClassBinder parent) : base(parent) {}
+
public void BindCompositeId(HbmCompositeId idSchema, PersistentClass rootClass)
{
if (idSchema == null)
+ {
return;
+ }
compositeId = new Component(rootClass);
rootClass.Identifier = compositeId;
@@ -28,12 +27,11 @@
}
else
{
- System.Type reflectedClass = GetPropertyType(rootClass.MappedClass,
- idSchema.name, idSchema);
+ System.Type reflectedClass = GetPropertyType(rootClass.MappedClass, idSchema.name, idSchema);
BindComponent(reflectedClass, idSchema.name, idSchema);
- Mapping.Property prop = new Mapping.Property(compositeId);
+ var prop = new Property(compositeId);
BindProperty(prop, idSchema);
rootClass.IdentifierProperty = prop;
}
@@ -43,24 +41,22 @@
System.Type compIdClass = compositeId.ComponentClass;
if (!ReflectHelper.OverridesEquals(compIdClass))
- throw new MappingException(
- "composite-id class must override Equals(): " + compIdClass.FullName
- );
+ {
+ throw new MappingException("composite-id class must override Equals(): " + compIdClass.FullName);
+ }
if (!ReflectHelper.OverridesGetHashCode(compIdClass))
- throw new MappingException(
- "composite-id class must override GetHashCode(): " + compIdClass.FullName
- );
+ {
+ throw new MappingException("composite-id class must override GetHashCode(): " + compIdClass.FullName);
+ }
// Serializability check not ported
}
- private void BindComponent(System.Type reflectedClass, string path,
- HbmCompositeId idSchema)
+ private void BindComponent(System.Type reflectedClass, string path, HbmCompositeId idSchema)
{
if (idSchema.@class != null)
{
- compositeId.ComponentClass = ClassForNameChecked(idSchema.@class, mappings,
- "component class not found: {0}");
+ compositeId.ComponentClass = ClassForNameChecked(idSchema.@class, mappings, "component class not found: {0}");
compositeId.IsEmbedded = false;
}
@@ -78,48 +74,45 @@
foreach (object item in idSchema.Items ?? new object[0])
{
- HbmKeyManyToOne keyManyToOneSchema = item as HbmKeyManyToOne;
- HbmKeyProperty keyPropertySchema = item as HbmKeyProperty;
+ var keyManyToOneSchema = item as HbmKeyManyToOne;
+ var keyPropertySchema = item as HbmKeyProperty;
if (keyManyToOneSchema != null)
{
- ManyToOne manyToOne = new ManyToOne(compositeId.Table);
+ var manyToOne = new ManyToOne(compositeId.Table);
- string propertyName = keyManyToOneSchema.name == null
- ? null
- : StringHelper.Qualify(path, keyManyToOneSchema.name);
+ string propertyName = keyManyToOneSchema.name == null ? null : StringHelper.Qualify(path, keyManyToOneSchema.name);
BindManyToOne(keyManyToOneSchema, manyToOne, propertyName, false);
- Mapping.Property property = CreateProperty(manyToOne, keyManyToOneSchema.name,
- compositeId.ComponentClass, keyManyToOneSchema);
+ Property property = CreateProperty(manyToOne, keyManyToOneSchema.name, compositeId.ComponentClass,
+ keyManyToOneSchema);
compositeId.AddProperty(property);
}
else if (keyPropertySchema != null)
{
- SimpleValue value = new SimpleValue(compositeId.Table);
+ var value = new SimpleValue(compositeId.Table);
- string propertyName = keyPropertySchema.name == null
- ? null
- : StringHelper.Qualify(path, keyPropertySchema.name);
+ string propertyName = keyPropertySchema.name == null ? null : StringHelper.Qualify(path, keyPropertySchema.name);
BindSimpleValue(keyPropertySchema, value, false, propertyName);
- Mapping.Property property = CreateProperty(value, keyPropertySchema.name,
- compositeId.ComponentClass, keyPropertySchema);
+ Property property = CreateProperty(value, keyPropertySchema.name, compositeId.ComponentClass, keyPropertySchema);
compositeId.AddProperty(property);
}
}
}
- private void BindProperty(Mapping.Property property, HbmCompositeId idSchema)
+ private void BindProperty(Property property, HbmCompositeId idSchema)
{
property.Name = idSchema.name;
if (property.Value.Type == null)
+ {
throw new MappingException("could not determine a property type for: " + property.Name);
+ }
property.PropertyAccessorName = idSchema.access ?? mappings.DefaultAccess;
property.Cascade = mappings.DefaultCascade;
@@ -132,14 +125,17 @@
LogMappedProperty(property);
}
- private System.Type GetPropertyType(System.Type containingType, string propertyName,
- HbmCompositeId idSchema)
+ private System.Type GetPropertyType(System.Type containingType, string propertyName, HbmCompositeId idSchema)
{
if (idSchema.@class != null)
+ {
return ClassForNameChecked(idSchema.@class, mappings, "could not find class: {0}");
+ }
else if (containingType == null)
+ {
return null;
+ }
else
{
@@ -149,14 +145,15 @@
}
private void BindManyToOne(HbmKeyManyToOne keyManyToOneSchema, ManyToOne manyToOne, string defaultColumnName,
- bool isNullable)
+ bool isNullable)
{
- BindColumns(keyManyToOneSchema, manyToOne, isNullable, true, defaultColumnName);
+ new ColumnsBinder(manyToOne, mappings).Bind(keyManyToOneSchema.Columns, isNullable,
+ () => new HbmColumn { name = mappings.NamingStrategy.PropertyToColumnName(defaultColumnName) });
manyToOne.FetchMode = FetchMode.Default;
manyToOne.IsLazy = !keyManyToOneSchema.lazySpecified
- ? manyToOne.IsLazy
- : keyManyToOneSchema.lazy == HbmRestrictedLaziness.Proxy;
+ ? manyToOne.IsLazy
+ : keyManyToOneSchema.lazy == HbmRestrictedLaziness.Proxy;
string typeNode = keyManyToOneSchema.@class;
if (typeNode != null)
@@ -171,81 +168,25 @@
manyToOne.IsIgnoreNotFound = false;
if (keyManyToOneSchema.foreignkey != null)
- manyToOne.ForeignKeyName = keyManyToOneSchema.foreignkey;
- }
-
- private void BindColumns(HbmKeyManyToOne keyManyToOneSchema, SimpleValue model, bool isNullable,
- bool autoColumn, string propertyPath)
- {
- Table table = model.Table;
- //COLUMN(S)
- if (keyManyToOneSchema.column1 == null)
{
- int count = 0;
-
- foreach (HbmColumn columnSchema in keyManyToOneSchema.column ?? new HbmColumn[0])
- {
- Column col = new Column();
- col.Value = model;
- col.TypeIndex = count++;
- BindColumn(columnSchema, col, isNullable);
-
- string name = columnSchema.name;
- col.Name = mappings.NamingStrategy.ColumnName(name);
- if (table != null)
- table.AddColumn(col);
- //table=null -> an association, fill it in later
- model.AddColumn(col);
-
- //column index
- BindIndex(columnSchema.index, table, col);
- //column group index (although it can serve as a separate column index)
-
- BindUniqueKey(columnSchema.uniquekey, table, col);
- }
+ manyToOne.ForeignKeyName = keyManyToOneSchema.foreignkey;
}
- else
- {
- Column col = new Column();
- col.Value = compositeId;
- BindColumn(col, isNullable);
- col.Name = mappings.NamingStrategy.ColumnName(keyManyToOneSchema.column1);
- if (table != null)
- table.AddColumn(col);
- model.AddColumn(col);
- //column group index (although can serve as a separate column index)
- }
-
- if (autoColumn && model.ColumnSpan == 0)
- {
- Column col = new Column();
- col.Value = model;
- BindColumn(col, isNullable);
- col.Name = mappings.NamingStrategy.PropertyToColumnName(propertyPath);
- model.Table.AddColumn(col);
- model.AddColumn(col);
- //column group index (although can serve as a separate column index)
- }
}
- private static void BindColumn(Column model, bool isNullable)
- {
- model.IsNullable = isNullable;
- model.IsUnique = false;
- model.CheckConstraint = string.Empty;
- model.SqlType = null;
- }
-
private Property CreateProperty(ToOne value, string propertyName, System.Type parentClass,
- HbmKeyManyToOne keyManyToOneSchema)
+ HbmKeyManyToOne keyManyToOneSchema)
{
if (parentClass != null && value.IsSimpleValue)
+ {
value.SetTypeUsingReflection(parentClass.AssemblyQualifiedName, propertyName,
keyManyToOneSchema.access ?? mappings.DefaultAccess);
+ }
string propertyRef = value.ReferencedPropertyName;
if (propertyRef != null)
+ {
mappings.AddUniquePropertyReference(value.ReferencedEntityName, propertyRef);
+ }
value.CreateForeignKey();
var prop = new Property {Value = value};
@@ -259,7 +200,9 @@
property.Name = keyManyToOneSchema.name;
if (property.Value.Type == null)
+ {
throw new MappingException("could not determine a property type for: " + property.Name);
+ }
property.PropertyAccessorName = keyManyToOneSchema.access ?? mappings.DefaultAccess;
property.Cascade = mappings.DefaultCascade;
@@ -275,80 +218,21 @@
private void BindSimpleValue(HbmKeyProperty keyPropertySchema, SimpleValue model, bool isNullable, string path)
{
if (keyPropertySchema.type1 != null)
- model.TypeName = keyPropertySchema.type1;
- BindColumns(keyPropertySchema, model, isNullable, true, path);
- }
-
- private void BindColumns(HbmKeyProperty keyPropertySchema, SimpleValue model, bool isNullable, bool autoColumn,
- string propertyPath)
- {
- Table table = model.Table;
-
- if (keyPropertySchema.column1 == null)
{
- int count = 0;
-
- foreach (HbmColumn columnSchema in keyPropertySchema.column ?? new HbmColumn[0])
- {
- Column col = new Column();
- col.Value = model;
- col.TypeIndex = count++;
- BindColumn(columnSchema, col, isNullable);
-
- col.Name = mappings.NamingStrategy.ColumnName(columnSchema.name);
- if (table != null)
- table.AddColumn(col);
- //table=null -> an association, fill it in later
- model.AddColumn(col);
-
- //column index
- BindIndex(columnSchema.index, table, col);
- //column group index (although it can serve as a separate column index)
-
- BindUniqueKey(columnSchema.uniquekey, table, col);
- }
+ model.TypeName = keyPropertySchema.type1;
}
- else
- {
- Column col = new Column();
- col.Value = compositeId;
- BindColumn(keyPropertySchema, col, isNullable);
- col.Name = mappings.NamingStrategy.ColumnName(keyPropertySchema.column1);
- if (table != null)
- table.AddColumn(col);
- model.AddColumn(col);
- //column group index (although can serve as a separate column index)
- }
-
- if (autoColumn && model.ColumnSpan == 0)
- {
- Column col = new Column();
- col.Value = model;
- BindColumn(keyPropertySchema, col, isNullable);
- col.Name = mappings.NamingStrategy.PropertyToColumnName(propertyPath);
- model.Table.AddColumn(col);
- model.AddColumn(col);
- //column group index (although can serve as a separate column index)
- }
+ new ColumnsBinder(model, Mappings).Bind(keyPropertySchema.Columns, isNullable,
+ () => new HbmColumn { name = mappings.NamingStrategy.PropertyToColumnName(path), length = keyPropertySchema.length });
}
- private static void BindColumn(HbmKeyProperty keyPropertySchema, Column model, bool isNullable)
- {
- if (keyPropertySchema.length != null)
- model.Length = int.Parse(keyPropertySchema.length);
-
- model.IsNullable = isNullable;
- model.IsUnique = false;
- model.CheckConstraint = string.Empty;
- model.SqlType = null;
- }
-
private Property CreateProperty(SimpleValue value, string propertyName, System.Type parentClass,
- HbmKeyProperty keyPropertySchema)
+ HbmKeyProperty keyPropertySchema)
{
if (parentClass != null && value.IsSimpleValue)
+ {
value.SetTypeUsingReflection(parentClass.AssemblyQualifiedName, propertyName,
keyPropertySchema.access ?? mappings.DefaultAccess);
+ }
// This is done here 'cos we might only know the type here (ugly!)
var toOne = value as ToOne;
@@ -356,7 +240,9 @@
{
string propertyRef = toOne.ReferencedPropertyName;
if (propertyRef != null)
+ {
mappings.AddUniquePropertyReference(toOne.ReferencedEntityName, propertyRef);
+ }
}
value.CreateForeignKey();
@@ -371,7 +257,9 @@
property.Name = keyPropertySchema.name;
if (property.Value.Type == null)
+ {
throw new MappingException("could not determine a property type for: " + property.Name);
+ }
property.PropertyAccessorName = keyPropertySchema.access ?? mappings.DefaultAccess;
property.Cascade = mappings.DefaultCascade;
Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassIdBinder.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassIdBinder.cs 2009-12-01 00:18:30 UTC (rev 4880)
+++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassIdBinder.cs 2009-12-01 14:26:29 UTC (rev 4881)
@@ -1,5 +1,5 @@
+using System;
using System.Collections.Generic;
-using System.Xml;
using NHibernate.Cfg.MappingSchema;
using NHibernate.Mapping;
using NHibernate.Util;
@@ -17,9 +17,16 @@
{
if (idSchema != null)
{
- SimpleValue id = CreateIdentifier(idSchema, rootClass, table);
+ var id = new SimpleValue(table) { TypeName = idSchema.type1 };
+ rootClass.Identifier = id;
- AddColumns(idSchema, id);
+ Func<HbmColumn> defaultColumn = () => new HbmColumn
+ {
+ name = idSchema.name ?? RootClass.DefaultIdentifierColumnName,
+ length = idSchema.length
+ };
+ new ColumnsBinder(id, Mappings).Bind(idSchema.Columns, false, defaultColumn);
+
CreateIdentifierProperty(idSchema, rootClass, id);
VerifiyIdTypeIsValid(id, rootClass.EntityName);
BindGenerator(idSchema, id);
@@ -28,26 +35,6 @@
}
}
- private static SimpleValue CreateIdentifier(HbmId idSchema, PersistentClass rootClass, Table table)
- {
- SimpleValue iv = new SimpleValue(table);
- iv.TypeName = idSchema.type1;
- rootClass.Identifier = iv;
-
- return iv;
- }
-
- private void AddColumns(HbmId idSchema, SimpleValue id)
- {
- if (idSchema.column1 != null)
- AddColumnFromAttribute(idSchema, id);
- else
- AddColumnsFromList(idSchema, id);
-
- if (id.ColumnSpan == 0)
- AddDefaultColumn(idSchema, id);
- }
-
private void CreateIdentifierProperty(HbmId idSchema, PersistentClass rootClass, SimpleValue id)
{
if (idSchema.name != null)
@@ -56,8 +43,7 @@
id.SetTypeUsingReflection(rootClass.MappedClass == null ? null : rootClass.MappedClass.AssemblyQualifiedName,
idSchema.name, access);
- Property property = new Property(id);
- property.Name = idSchema.name;
+ var property = new Property(id) {Name = idSchema.name};
if (property.Value.Type == null)
throw new MappingException("could not determine a property type for: " + property.Name);
@@ -68,7 +54,7 @@
property.IsInsertable = true;
property.IsOptimisticLocked = true;
property.Generation = PropertyGeneration.Never;
- property.MetaAttributes = GetMetas(idSchema);
+ property.MetaAttributes = GetMetas(idSchema, EmptyMeta);
rootClass.IdentifierProperty = property;
@@ -114,7 +100,7 @@
private IDictionary<string,string> GetGeneratorProperties(HbmId idSchema, IValue id)
{
- Dictionary<string, string> results = new Dictionary<string, string>();
+ var results = new Dictionary<string, string>();
if (id.Table.Schema != null)
results.Add(Id.PersistentIdGeneratorParmsNames.Schema, id.Table.Schema);
@@ -131,110 +117,5 @@
{
id.NullValue = idSchema.unsavedvalue ?? (id.IdentifierGeneratorStrategy == "assigned" ? "undefined" : null);
}
-
- private void AddColumnFromAttribute(HbmId idSchema, SimpleValue id)
- {
- Column column = CreateColumn(idSchema);
- column.Value = id;
- column.Name = mappings.NamingStrategy.ColumnName(idSchema.column1);
-
- if (id.Table != null)
- id.Table.AddColumn(column);
-
- id.AddColumn(column);
- }
-
- private void AddColumnsFromList(HbmId idSchema, SimpleValue id)
- {
- int count = 0;
-
- foreach (HbmColumn columnSchema in idSchema.column ?? new HbmColumn[0])
- {
- Column column = CreateColumn(columnSchema, id, count++);
- column.Name = mappings.NamingStrategy.ColumnName(columnSchema.name);
-
- if (id.Table != null)
- id.Table.AddColumn(column);
- //table=null -> an association, fill it in later
-
- id.AddColumn(column);
-
- if (columnSchema.index != null && id.Table != null)
- {
- var tokens = new StringTokenizer(columnSchema.index, ",", false);
- foreach (string token in tokens)
- id.Table.GetOrCreateIndex(token.Trim()).AddColumn(column);
- }
-
- if (columnSchema.uniquekey != null && id.Table != null)
- {
- var tokens = new StringTokenizer(columnSchema.uniquekey, ",", false);
- foreach (string token in tokens)
- id.Table.GetOrCreateUniqueKey(token.Trim()).AddColumn(column);
- }
- }
- }
-
- private void AddDefaultColumn(HbmId idSchema, SimpleValue id)
- {
- Column column = CreateColumn(idSchema);
- column.Value = id;
- string propertyName = idSchema.name ?? RootClass.DefaultIdentifierColumnName;
- column.Name = mappings.NamingStrategy.PropertyToColumnName(propertyName);
-
- id.Table.AddColumn(column);
- id.AddColumn(column);
- }
-
- private static IDictionary<string, MetaAttribute> GetMetas(HbmId idSchema)
- {
- Dictionary<string, MetaAttribute> map = new Dictionary<string, MetaAttribute>();
-
- foreach (HbmMeta metaSchema in idSchema.meta ?? new HbmMeta[0])
- {
- MetaAttribute meta;
- if (!map.TryGetValue(metaSchema.attribute, out meta))
- {
- meta = new MetaAttribute(metaSchema.attribute);
- map[metaSchema.attribute] = meta;
- }
-
- meta.AddValue(metaSchema.GetText());
- }
-
- return map;
- }
-
- private static Column CreateColumn(HbmId idSchema)
- {
- Column column = new Column();
-
- if (idSchema.length != null)
- column.Length = int.Parse(idSchema.length);
-
- column.IsNullable = false;
- column.IsUnique = false;
- column.CheckConstraint = string.Empty;
- column.SqlType = null;
-
- return column;
- }
-
- private static Column CreateColumn(HbmColumn columnSchema, IValue type, int index)
- {
- Column column = new Column();
- column.Value = type;
- column.TypeIndex = index;
-
- if (columnSchema.length != null)
- column.Length = int.Parse(columnSchema.length);
-
- column.IsNullable = columnSchema.notnullSpecified ? !columnSchema.notnull : false;
- column.IsUnique = columnSchema.uniqueSpecified && columnSchema.unique;
- column.CheckConstraint = columnSchema.check ?? string.Empty;
- column.SqlType = columnSchema.sqltype;
-
- return column;
- }
}
}
Added: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ColumnsBinder.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ColumnsBinder.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ColumnsBinder.cs 2009-12-01 14:26:29 UTC (rev 4881)
@@ -0,0 +1,88 @@
+using System;
+using System.Collections.Generic;
+using NHibernate.Cfg.MappingSchema;
+using NHibernate.Mapping;
+using NHibernate.Util;
+
+namespace NHibernate.Cfg.XmlHbmBinding
+{
+ public class ColumnsBinder: Binder
+ {
+ private readonly SimpleValue value;
+
+ public ColumnsBinder(SimpleValue value, Mappings mappings)
+ : base(mappings)
+ {
+ this.value = value;
+ }
+
+ public void Bind(IEnumerable<HbmColumn> columns, bool isNullable, Func<HbmColumn> defaultColumnDelegate)
+ {
+ var table = value.Table;
+ int colIndex = 0;
+ foreach (var hbmColumn in columns)
+ {
+ BindColumn(hbmColumn, table, colIndex++, isNullable);
+ }
+
+ if (value.ColumnSpan == 0 && defaultColumnDelegate != null)
+ {
+ BindColumn(defaultColumnDelegate(), table, colIndex, isNullable);
+ }
+ }
+
+ private void BindColumn(HbmColumn hbmColumn, Table table, int colIndex, bool isNullable)
+ {
+ var col = new Column {Value = value, TypeIndex = colIndex};
+ BindColumn(hbmColumn, col, isNullable);
+
+ if (table != null)
+ table.AddColumn(col);
+
+ value.AddColumn(col);
+
+ //column index
+ BindIndex(hbmColumn.index, table, col);
+ //column group index (although it can serve as a separate column index)
+ BindUniqueKey(hbmColumn.uniquekey, table, col);
+ }
+
+ private void BindColumn(HbmColumn columnMapping, Column column, bool isNullable)
+ {
+ column.Name = mappings.NamingStrategy.ColumnName(columnMapping.name);
+
+ if (columnMapping.length != null)
+ column.Length = int.Parse(columnMapping.length);
+ if (columnMapping.scale != null)
+ column.Scale = int.Parse(columnMapping.scale);
+ if (columnMapping.precision != null)
+ column.Precision = int.Parse(columnMapping.precision);
+
+ column.IsNullable = columnMapping.notnullSpecified ? !columnMapping.notnull : isNullable;
+ column.IsUnique = columnMapping.uniqueSpecified && columnMapping.unique;
+ column.CheckConstraint = columnMapping.check ?? string.Empty;
+ column.SqlType = columnMapping.sqltype;
+ column.DefaultValue = columnMapping.@default;
+ if (columnMapping.comment != null)
+ column.Comment = columnMapping.comment.Text.LinesToString().Trim();
+ }
+
+ private static void BindIndex(string indexAttribute, Table table, Column column)
+ {
+ if (indexAttribute != null && table != null)
+ {
+ var tokens = indexAttribute.Split(',');
+ System.Array.ForEach(tokens, t => table.GetOrCreateIndex(t.Trim()).AddColumn(column));
+ }
+ }
+
+ private static void BindUniqueKey(string uniqueKeyAttribute, Table table, Column column)
+ {
+ if (uniqueKeyAttribute != null && table != null)
+ {
+ var tokens = uniqueKeyAttribute.Split(',');
+ System.Array.ForEach(tokens, t => table.GetOrCreateUniqueKey(t.Trim()).AddColumn(column));
+ }
+ }
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-12-01 00:18:30 UTC (rev 4880)
+++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-12-01 14:26:29 UTC (rev 4881)
@@ -545,6 +545,7 @@
<Compile Include="Cfg\MappingSchema\HbmTimestamp.cs" />
<Compile Include="Cfg\MappingSchema\HbmVersion.cs" />
<Compile Include="Cfg\MappingSchema\IDecoratable.cs" />
+ <Compile Include="Cfg\XmlHbmBinding\ColumnsBinder.cs" />
<Compile Include="Cfg\XmlHbmBinding\FiltersBinder.cs" />
<Compile Include="Cfg\XmlHbmBinding\PropertiesBinder.cs">
<SubType>Code</SubType>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2009-12-01 16:47:48
|
Revision: 4884
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4884&view=rev
Author: fabiomaulo
Date: 2009-12-01 16:47:38 +0000 (Tue, 01 Dec 2009)
Log Message:
-----------
Preparing other binders refactoring
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmElement.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmId.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmKeyProperty.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmProperty.cs
trunk/nhibernate/src/NHibernate/NHibernate.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/ITypeMapping.cs
Modified: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmElement.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmElement.cs 2009-12-01 16:31:59 UTC (rev 4883)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmElement.cs 2009-12-01 16:47:38 UTC (rev 4884)
@@ -4,7 +4,7 @@
namespace NHibernate.Cfg.MappingSchema
{
- public partial class HbmElement: IColumnsMapping, IFormulasMapping
+ public partial class HbmElement: IColumnsMapping, IFormulasMapping, ITypeMapping
{
#region Implementation of IColumnsMapping
@@ -56,5 +56,15 @@
}
#endregion
+
+
+ #region Implementation of ITypeMapping
+
+ public HbmType Type
+ {
+ get { return type ?? (!string.IsNullOrEmpty(type1) ? new HbmType { name = type1 } : null); }
+ }
+
+ #endregion
}
}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmId.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmId.cs 2009-12-01 16:31:59 UTC (rev 4883)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmId.cs 2009-12-01 16:47:38 UTC (rev 4884)
@@ -3,7 +3,7 @@
namespace NHibernate.Cfg.MappingSchema
{
- public partial class HbmId: AbstractDecoratable, IColumnsMapping
+ public partial class HbmId: AbstractDecoratable, IColumnsMapping, ITypeMapping
{
#region Implementation of IColumnsMapping
@@ -38,5 +38,14 @@
}
#endregion
+
+ #region Implementation of ITypeMapping
+
+ public HbmType Type
+ {
+ get { return type ?? (!string.IsNullOrEmpty(type1) ? new HbmType { name = type1 } : null); }
+ }
+
+ #endregion
}
}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmKeyProperty.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmKeyProperty.cs 2009-12-01 16:31:59 UTC (rev 4883)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmKeyProperty.cs 2009-12-01 16:47:38 UTC (rev 4884)
@@ -2,7 +2,7 @@
namespace NHibernate.Cfg.MappingSchema
{
- public partial class HbmKeyProperty: IColumnsMapping
+ public partial class HbmKeyProperty: IColumnsMapping, ITypeMapping
{
#region Implementation of IColumnsMapping
@@ -29,5 +29,14 @@
};
}
}
+
+ #region Implementation of ITypeMapping
+
+ public HbmType Type
+ {
+ get { return type ?? (!string.IsNullOrEmpty(type1) ? new HbmType { name = type1 } : null); }
+ }
+
+ #endregion
}
}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmProperty.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmProperty.cs 2009-12-01 16:31:59 UTC (rev 4883)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmProperty.cs 2009-12-01 16:47:38 UTC (rev 4884)
@@ -4,7 +4,7 @@
namespace NHibernate.Cfg.MappingSchema
{
- public partial class HbmProperty : AbstractDecoratable, IEntityPropertyMapping, IColumnsMapping, IFormulasMapping
+ public partial class HbmProperty : AbstractDecoratable, IEntityPropertyMapping, IColumnsMapping, IFormulasMapping, ITypeMapping
{
#region Implementation of IEntityPropertyMapping
@@ -87,5 +87,14 @@
}
#endregion
+
+ #region Implementation of ITypeMapping
+
+ public HbmType Type
+ {
+ get { return type ?? (!string.IsNullOrEmpty(type1) ? new HbmType {name = type1} : null); }
+ }
+
+ #endregion
}
}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/ITypeMapping.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/ITypeMapping.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/ITypeMapping.cs 2009-12-01 16:47:38 UTC (rev 4884)
@@ -0,0 +1,7 @@
+namespace NHibernate.Cfg.MappingSchema
+{
+ public interface ITypeMapping
+ {
+ HbmType Type { get; }
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-12-01 16:31:59 UTC (rev 4883)
+++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-12-01 16:47:38 UTC (rev 4884)
@@ -538,6 +538,7 @@
<Compile Include="Cfg\MappingSchema\IFormulasMapping.cs" />
<Compile Include="Cfg\MappingSchema\IPropertiesContainerMapping.cs" />
<Compile Include="Cfg\MappingSchema\IReferencePropertyMapping.cs" />
+ <Compile Include="Cfg\MappingSchema\ITypeMapping.cs" />
<Compile Include="Cfg\SchemaAutoAction.cs" />
<Compile Include="Cfg\SessionFactoryConfigurationBase.cs" />
<Compile Include="Cfg\ISessionFactoryConfiguration.cs" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2009-12-01 21:03:51
|
Revision: 4885
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4885&view=rev
Author: fabiomaulo
Date: 2009-12-01 21:03:41 +0000 (Tue, 01 Dec 2009)
Log Message:
-----------
binders refactoring
- TypeBinder partially on the road
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/RootClassBinder.cs
trunk/nhibernate/src/NHibernate/NHibernate.csproj
trunk/nhibernate/src/NHibernate/Util/ArrayHelper.cs
Added Paths:
-----------
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/TypeBinder.cs
Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/RootClassBinder.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/RootClassBinder.cs 2009-12-01 16:47:38 UTC (rev 4884)
+++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/RootClassBinder.cs 2009-12-01 21:03:41 UTC (rev 4885)
@@ -197,7 +197,7 @@
string propertyName = versionSchema.name;
var simpleValue = new SimpleValue(table);
- BindVersionType(versionSchema.type, simpleValue);
+ new TypeBinder(simpleValue, Mappings).Bind(versionSchema.type);
new ColumnsBinder(simpleValue, Mappings).Bind(versionSchema.Columns, false,
() =>
new HbmColumn
@@ -221,13 +221,6 @@
rootClass.AddProperty(property);
}
- private void BindVersionType(string versionTypeName, SimpleValue simpleValue)
- {
- if (versionTypeName == null)
- return;
- BindTypeDef(versionTypeName, versionTypeName, new Dictionary<string, string>(), simpleValue);
- }
-
private void BindProperty(HbmVersion versionSchema, Property property, IDictionary<string, MetaAttribute> inheritedMetas)
{
property.Name = versionSchema.name;
Added: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/TypeBinder.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/TypeBinder.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/TypeBinder.cs 2009-12-01 21:03:41 UTC (rev 4885)
@@ -0,0 +1,85 @@
+using System;
+using System.Collections.Generic;
+using NHibernate.Cfg.MappingSchema;
+using NHibernate.Mapping;
+using NHibernate.Util;
+
+namespace NHibernate.Cfg.XmlHbmBinding
+{
+ public class TypeBinder: Binder
+ {
+ private readonly SimpleValue value;
+
+ public TypeBinder(SimpleValue value, Mappings mappings)
+ : base(mappings)
+ {
+ if (value == null)
+ {
+ throw new ArgumentNullException("value");
+ }
+ this.value = value;
+ }
+
+ public void Bind(string typeName)
+ {
+ if(string.IsNullOrEmpty(typeName))
+ {
+ return;
+ }
+ Bind(new HbmType { name= typeName });
+ }
+
+ private void Bind(HbmType typeMapping)
+ {
+ if (typeMapping == null)
+ {
+ throw new ArgumentNullException("typeMapping");
+ }
+ string originalTypeName = typeMapping.name;
+ if(originalTypeName == null)
+ {
+ return;
+ }
+ var parameters = new Dictionary<string, string>();
+ if(typeMapping.param != null)
+ {
+ System.Array.ForEach(typeMapping.param, p => parameters[p.name] = p.Text.LinesToString());
+ }
+
+ BindThroughTypeDefOrType(originalTypeName, parameters);
+ }
+
+ private void BindThroughTypeDefOrType(string originalTypeName, IDictionary<string, string> parameters)
+ {
+ string typeName = null;
+ TypeDef typeDef = Mappings.GetTypeDef(originalTypeName);
+ if (typeDef != null)
+ {
+ typeName = FullQualifiedClassName(typeDef.TypeClass, Mappings);
+ // parameters on the property mapping should
+ // override parameters in the typedef
+ parameters = new Dictionary<string, string>(typeDef.Parameters).AddOrOverride(parameters);
+ }
+ else if (NeedQualifiedClassName(originalTypeName)
+ && (typeDef = Mappings.GetTypeDef(FullQualifiedClassName(originalTypeName, Mappings))) != null)
+ {
+ // NH: allow className completing it with assembly+namespace of the mapping doc.
+ typeName = typeDef.TypeClass;
+ // parameters on the property mapping should
+ // override parameters in the typedef
+ parameters = new Dictionary<string, string>(typeDef.Parameters).AddOrOverride(parameters);
+ }
+
+ if (parameters.Count != 0)
+ {
+ value.TypeParameters = parameters;
+ }
+ var typeToMap = typeName ?? originalTypeName;
+ if (NeedQualifiedClassName(typeToMap))
+ {
+ typeToMap = FullQualifiedClassName(typeToMap, Mappings);
+ }
+ value.TypeName = typeToMap;
+ }
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-12-01 16:47:38 UTC (rev 4884)
+++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-12-01 21:03:41 UTC (rev 4885)
@@ -551,6 +551,7 @@
<Compile Include="Cfg\XmlHbmBinding\PropertiesBinder.cs">
<SubType>Code</SubType>
</Compile>
+ <Compile Include="Cfg\XmlHbmBinding\TypeBinder.cs" />
<Compile Include="Context\WcfOperationSessionContext.cs" />
<Compile Include="Criterion\GroupedProjection.cs" />
<Compile Include="Criterion\IPropertyProjection.cs" />
Modified: trunk/nhibernate/src/NHibernate/Util/ArrayHelper.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Util/ArrayHelper.cs 2009-12-01 16:47:38 UTC (rev 4884)
+++ trunk/nhibernate/src/NHibernate/Util/ArrayHelper.cs 2009-12-01 21:03:41 UTC (rev 4885)
@@ -12,7 +12,7 @@
/// Helper class that contains common array functions and
/// data structures used through out NHibernate.
/// </summary>
- public sealed class ArrayHelper
+ public static class ArrayHelper
{
public static readonly object[] EmptyObjectArray = new object[0];
public static readonly IType[] EmptyTypeArray = new IType[0];
@@ -22,10 +22,6 @@
public static readonly bool[] True = new bool[] { true };
public static readonly bool[] False = new bool[] { false };
- private ArrayHelper()
- {
- }
-
public static bool IsAllNegative(int[] array)
{
for (int i = 0; i < array.Length; i++)
@@ -226,6 +222,16 @@
}
}
+ public static IDictionary<TKey, TValue> AddOrOverride<TKey, TValue>(this IDictionary<TKey, TValue> destination, IDictionary<TKey, TValue> sourceOverride)
+ {
+ foreach (KeyValuePair<TKey, TValue> de in sourceOverride)
+ {
+ // we want to override the values from to if they exists
+ destination[de.Key] = de.Value;
+ }
+ return destination;
+ }
+
public static int[] GetBatchSizes(int maxBatchSize)
{
int batchSize = maxBatchSize;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ste...@us...> - 2009-12-01 22:08:36
|
Revision: 4886
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4886&view=rev
Author: steverstrong
Date: 2009-12-01 22:08:23 +0000 (Tue, 01 Dec 2009)
Log Message:
-----------
Changes to HQLQueryPlan and IQueryTranslatorFactory to support polymorphic Linq queries
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Engine/Query/FilterQueryPlan.cs
trunk/nhibernate/src/NHibernate/Engine/Query/HQLQueryPlan.cs
trunk/nhibernate/src/NHibernate/Engine/Query/QueryPlanCache.cs
trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/ASTQueryTranslatorFactory.cs
trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlParser.cs
trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlToken.cs
trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QueryTranslatorImpl.cs
trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ASTNode.cs
trunk/nhibernate/src/NHibernate/Hql/Classic/ClassicQueryTranslatorFactory.cs
trunk/nhibernate/src/NHibernate/Hql/IQueryTranslatorFactory.cs
trunk/nhibernate/src/NHibernate/Impl/AbstractSessionImpl.cs
trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs
trunk/nhibernate/src/NHibernate/Impl/StatelessSessionImpl.cs
trunk/nhibernate/src/NHibernate/Linq/Visitors/HqlGeneratorExpressionTreeVisitor.cs
trunk/nhibernate/src/NHibernate.Test/App.config
trunk/nhibernate/src/NHibernate.Test/BulkManipulation/BaseFixture.cs
trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BaseFixture.cs
trunk/nhibernate/src/NHibernate.Test/HQL/Ast/HqlFixture.cs
trunk/nhibernate/src/NHibernate.Test/Linq/MiscellaneousTextFixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1849/Fixture.cs
Modified: trunk/nhibernate/src/NHibernate/Engine/Query/FilterQueryPlan.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Engine/Query/FilterQueryPlan.cs 2009-12-01 21:03:41 UTC (rev 4885)
+++ trunk/nhibernate/src/NHibernate/Engine/Query/FilterQueryPlan.cs 2009-12-01 22:08:23 UTC (rev 4886)
@@ -8,7 +8,7 @@
/// being filtered.
/// </summary>
[Serializable]
- public class FilterQueryPlan : HQLQueryPlan
+ public class FilterQueryPlan : HQLStringQueryPlan
{
private readonly string collectionRole;
Modified: trunk/nhibernate/src/NHibernate/Engine/Query/HQLQueryPlan.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Engine/Query/HQLQueryPlan.cs 2009-12-01 21:03:41 UTC (rev 4885)
+++ trunk/nhibernate/src/NHibernate/Engine/Query/HQLQueryPlan.cs 2009-12-01 22:08:23 UTC (rev 4886)
@@ -7,258 +7,86 @@
using NHibernate.Event;
using NHibernate.Hql;
using NHibernate.Hql.Ast.ANTLR;
+using NHibernate.Impl;
using NHibernate.Type;
using NHibernate.Util;
namespace NHibernate.Engine.Query
{
+ public interface IQueryPlan
+ {
+ ParameterMetadata ParameterMetadata { get; }
+ ISet<string> QuerySpaces { get; }
+ IQueryTranslator[] Translators { get; }
+ ReturnMetadata ReturnMetadata { get; }
+ void PerformList(QueryParameters queryParameters, ISessionImplementor statelessSessionImpl, IList results);
+ int PerformExecuteUpdate(QueryParameters queryParameters, ISessionImplementor statelessSessionImpl);
+ IEnumerable<T> PerformIterate<T>(QueryParameters queryParameters, IEventSource session);
+ IEnumerable PerformIterate(QueryParameters queryParameters, IEventSource session);
+ }
+
+ public interface IQueryExpressionPlan : IQueryPlan
+ {
+ IQueryExpression QueryExpression { get; }
+ }
+
/// <summary> Defines a query execution plan for an HQL query (or filter). </summary>
[Serializable]
- public class HQLQueryPlan
+ public class HQLQueryPlan : IQueryPlan
{
- private static readonly ILog log = LogManager.GetLogger(typeof(HQLQueryPlan));
+ protected static readonly ILog Log = LogManager.GetLogger(typeof(HQLQueryPlan));
- private readonly string sourceQuery;
- private readonly IQueryTranslator[] translators;
- private readonly string[] sqlStrings;
+ private readonly string _sourceQuery;
- private readonly ParameterMetadata parameterMetadata;
- private readonly ReturnMetadata returnMetadata;
- private readonly HashedSet<string> querySpaces;
-
- private readonly HashedSet<string> enabledFilterNames;
- private readonly bool shallow;
- private IQueryExpression sourceQueryExpression;
-
- public HQLQueryPlan(string hql, bool shallow,
- IDictionary<string, IFilter> enabledFilters, ISessionFactoryImplementor factory)
- : this(hql, (string) null, shallow, enabledFilters, factory)
- {
- }
-
- public HQLQueryPlan(string expressionStr, IQueryExpression queryExpression, bool shallow,
- IDictionary<string, IFilter> enabledFilters, ISessionFactoryImplementor factory)
- : this(expressionStr, queryExpression, null, shallow, enabledFilters, factory)
+ protected HQLQueryPlan(string sourceQuery)
{
+ _sourceQuery = sourceQuery;
}
- protected internal HQLQueryPlan(string hql, string collectionRole, bool shallow,
- IDictionary<string, IFilter> enabledFilters, ISessionFactoryImplementor factory)
- {
- sourceQuery = hql;
- this.shallow = shallow;
-
- enabledFilterNames = new HashedSet<string>(enabledFilters.Keys);
-
- HashedSet<string> combinedQuerySpaces = new HashedSet<string>();
- string[] concreteQueryStrings = QuerySplitter.ConcreteQueries(hql, factory);
- int length = concreteQueryStrings.Length;
- translators = new IQueryTranslator[length];
- List<string> sqlStringList = new List<string>();
- for (int i = 0; i < length; i++)
- {
- if (collectionRole == null)
- {
- translators[i] =
- factory.Settings.QueryTranslatorFactory.CreateQueryTranslator(hql, concreteQueryStrings[i], enabledFilters,
- factory);
- translators[i].Compile(factory.Settings.QuerySubstitutions, shallow);
- }
- else
- {
- translators[i] =
- factory.Settings.QueryTranslatorFactory.CreateFilterTranslator(hql, concreteQueryStrings[i], enabledFilters,
- factory);
- ((IFilterTranslator)translators[i]).Compile(collectionRole, factory.Settings.QuerySubstitutions, shallow);
- }
- foreach (string qs in translators[i].QuerySpaces)
- {
- combinedQuerySpaces.Add(qs);
- }
- sqlStringList.AddRange(translators[i].CollectSqlStrings);
- }
-
- sqlStrings = sqlStringList.ToArray();
- querySpaces = combinedQuerySpaces;
-
- if (length == 0)
- {
- parameterMetadata = new ParameterMetadata(null, null);
- returnMetadata = null;
- }
- else
- {
- parameterMetadata = BuildParameterMetadata(translators[0].GetParameterTranslations(), hql);
- if (translators[0].IsManipulationStatement)
- {
- returnMetadata = null;
- }
- else
- {
- if (length > 1)
- {
- int returns = translators[0].ReturnTypes.Length;
- returnMetadata = new ReturnMetadata(translators[0].ReturnAliases, new IType[returns]);
- }
- else
- {
- returnMetadata = new ReturnMetadata(translators[0].ReturnAliases, translators[0].ReturnTypes);
- }
- }
- }
- }
-
- protected internal HQLQueryPlan(string expressionStr, IQueryExpression queryExpression, string collectionRole, bool shallow,
- IDictionary<string, IFilter> enabledFilters, ISessionFactoryImplementor factory)
- {
- sourceQueryExpression = queryExpression;
- sourceQuery = expressionStr;
- this.shallow = shallow;
-
- enabledFilterNames = new HashedSet<string>(enabledFilters.Keys);
-
- // TODO - no support for polymorphism here - done during Expression -> AST translation?
- // TODO - polymorphism approach used in method above also sucks. Could be done in AST much more cleanly? Look at this...
- IQueryTranslatorFactory2 qtFactory = new ASTQueryTranslatorFactory();
-
- IQueryTranslator translator = qtFactory.CreateQueryTranslator(expressionStr, queryExpression, enabledFilters,
- factory);
-
- translator.Compile(factory.Settings.QuerySubstitutions, shallow);
-
- translators = new[] { translator };
-
- sqlStrings = new List<string>(translator.CollectSqlStrings).ToArray();
-
- querySpaces = new HashedSet<string>(translator.QuerySpaces);
-
- var parameterTranslations = translator.GetParameterTranslations();
-
- var namedParamDescriptorMap = new Dictionary<string, NamedParameterDescriptor>();
- foreach (NamedParameterDescriptor entry in queryExpression.ParameterDescriptors)
- {
- namedParamDescriptorMap[entry.Name] =
- new NamedParameterDescriptor(entry.Name, parameterTranslations.GetNamedParameterExpectedType(entry.Name),
- entry.SourceLocations, entry.JpaStyle);
- }
-
- parameterMetadata = new ParameterMetadata(new OrdinalParameterDescriptor[0], namedParamDescriptorMap);
-
- returnMetadata = new ReturnMetadata(translator.ReturnAliases, translator.ReturnTypes);
- }
-
- public string SourceQuery
- {
- get { return sourceQuery; }
- }
-
public ISet<string> QuerySpaces
{
- get { return querySpaces; }
+ get;
+ protected set;
}
public ParameterMetadata ParameterMetadata
{
- get { return parameterMetadata; }
- }
+ get;
+ protected set;
+ }
public ReturnMetadata ReturnMetadata
{
- get { return returnMetadata; }
- }
+ get;
+ protected set;
+ }
- public ISet EnabledFilterNames
- {
- get { return enabledFilterNames; }
- }
-
public string[] SqlStrings
{
- get { return sqlStrings; }
- }
+ get;
+ protected set;
+ }
- public ISet UtilizedFilterNames
- {
- get
- {
- // TODO : add this info to the translator and aggregate it here...
- return null;
- }
- }
-
- public bool Shallow
- {
- get { return shallow; }
- }
-
public IQueryTranslator[] Translators
{
- get
- {
- IQueryTranslator[] copy = new IQueryTranslator[translators.Length];
- Array.Copy(translators, 0, copy, 0, copy.Length);
- return copy;
- }
- }
+ get;
+ protected set;
+ }
- public IQueryExpression QueryExpression
- {
- get { return sourceQueryExpression; }
- }
-
- private static ParameterMetadata BuildParameterMetadata(IParameterTranslations parameterTranslations, string hql)
- {
- long start = DateTime.Now.Ticks;
- ParamLocationRecognizer recognizer = ParamLocationRecognizer.ParseLocations(hql);
- long end = DateTime.Now.Ticks;
- if (log.IsDebugEnabled)
- {
- log.Debug("HQL param location recognition took " + (end - start) + " mills (" + hql + ")");
- }
-
- int ordinalParamCount = parameterTranslations.OrdinalParameterCount;
- int[] locations = recognizer.OrdinalParameterLocationList.ToArray();
- if (parameterTranslations.SupportsOrdinalParameterMetadata && locations.Length != ordinalParamCount)
- {
- throw new HibernateException("ordinal parameter mismatch");
- }
- ordinalParamCount = locations.Length;
- OrdinalParameterDescriptor[] ordinalParamDescriptors = new OrdinalParameterDescriptor[ordinalParamCount];
- for (int i = 1; i <= ordinalParamCount; i++)
- {
- ordinalParamDescriptors[i - 1] =
- new OrdinalParameterDescriptor(i,
- parameterTranslations.SupportsOrdinalParameterMetadata
- ? parameterTranslations.GetOrdinalParameterExpectedType(i)
- : null, locations[i - 1]);
- }
-
- Dictionary<string, NamedParameterDescriptor> namedParamDescriptorMap = new Dictionary<string, NamedParameterDescriptor>();
- foreach (KeyValuePair<string, ParamLocationRecognizer.NamedParameterDescription> entry in recognizer.NamedParameterDescriptionMap)
- {
- string name = entry.Key;
- ParamLocationRecognizer.NamedParameterDescription description = entry.Value;
- namedParamDescriptorMap[name] =
- new NamedParameterDescriptor(name, parameterTranslations.GetNamedParameterExpectedType(name),
- description.BuildPositionsArray(), description.JpaStyle);
-
- }
- return new ParameterMetadata(ordinalParamDescriptors, namedParamDescriptorMap);
- }
-
public void PerformList(QueryParameters queryParameters, ISessionImplementor session, IList results)
{
- if (log.IsDebugEnabled)
+ if (Log.IsDebugEnabled)
{
- log.Debug("find: " + SourceQuery);
+ Log.Debug("find: " + _sourceQuery);
queryParameters.LogParameters(session.Factory);
}
+
bool hasLimit = queryParameters.RowSelection != null && queryParameters.RowSelection.DefinesLimits;
- bool needsLimit = hasLimit && translators.Length > 1;
+ bool needsLimit = hasLimit && Translators.Length > 1;
QueryParameters queryParametersToUse;
if (needsLimit)
{
- log.Warn("firstResult/maxResults specified on polymorphic query; applying in memory!");
+ Log.Warn("firstResult/maxResults specified on polymorphic query; applying in memory!");
RowSelection selection = new RowSelection();
selection.FetchSize = queryParameters.RowSelection.FetchSize;
selection.Timeout = queryParameters.RowSelection.Timeout;
@@ -272,9 +100,9 @@
IList combinedResults = results ?? new List<object>();
IdentitySet distinction = new IdentitySet();
int includedCount = -1;
- for (int i = 0; i < translators.Length; i++)
+ for (int i = 0; i < Translators.Length; i++)
{
- IList tmp = translators[i].List(session, queryParametersToUse);
+ IList tmp = Translators[i].List(session, queryParametersToUse);
if (needsLimit)
{
// NOTE : firstRow is zero-based
@@ -333,28 +161,28 @@
{
isMany = null;
results = null;
- if (log.IsDebugEnabled)
+ if (Log.IsDebugEnabled)
{
- log.Debug("enumerable: " + SourceQuery);
+ Log.Debug("enumerable: " + _sourceQuery);
queryParameters.LogParameters(session.Factory);
}
- if (translators.Length == 0)
+ if (Translators.Length == 0)
{
result = CollectionHelper.EmptyEnumerable;
}
else
{
results = null;
- bool many = translators.Length > 1;
+ bool many = Translators.Length > 1;
if (many)
{
- results = new IEnumerable[translators.Length];
+ results = new IEnumerable[Translators.Length];
}
result = null;
- for (int i = 0; i < translators.Length; i++)
+ for (int i = 0; i < Translators.Length; i++)
{
- result = translators[i].GetEnumerable(queryParameters, session);
+ result = Translators[i].GetEnumerable(queryParameters, session);
if (many)
results[i] = result;
}
@@ -364,22 +192,191 @@
public int PerformExecuteUpdate(QueryParameters queryParameters, ISessionImplementor session)
{
- if (log.IsDebugEnabled)
+ if (Log.IsDebugEnabled)
{
- log.Debug("executeUpdate: " + SourceQuery);
+ Log.Debug("executeUpdate: " + _sourceQuery);
queryParameters.LogParameters(session.Factory);
}
- if (translators.Length != 1)
+ if (Translators.Length != 1)
{
- log.Warn("manipulation query [" + SourceQuery + "] resulted in [" + translators.Length + "] split queries");
+ Log.Warn("manipulation query [" + _sourceQuery + "] resulted in [" + Translators.Length + "] split queries");
}
int result = 0;
- for (int i = 0; i < translators.Length; i++)
+ for (int i = 0; i < Translators.Length; i++)
{
- result += translators[i].ExecuteUpdate(queryParameters, session);
+ result += Translators[i].ExecuteUpdate(queryParameters, session);
}
return result;
}
- }
+ protected void BuildSqlStringsAndQuerySpaces()
+ {
+ var combinedQuerySpaces = new HashedSet<string>();
+ var sqlStringList = new List<string>();
+
+ foreach (var translator in Translators)
+ {
+ foreach (var qs in translator.QuerySpaces)
+ {
+ combinedQuerySpaces.Add(qs);
+ }
+
+ sqlStringList.AddRange(translator.CollectSqlStrings);
+ }
+
+ SqlStrings = sqlStringList.ToArray();
+ QuerySpaces = combinedQuerySpaces;
+ }
+ }
+
+ [Serializable]
+ public class HQLStringQueryPlan : HQLQueryPlan
+ {
+ public HQLStringQueryPlan(string hql, bool shallow,
+ IDictionary<string, IFilter> enabledFilters, ISessionFactoryImplementor factory)
+ : this(hql, (string) null, shallow, enabledFilters, factory)
+ {
+ }
+
+ protected internal HQLStringQueryPlan(string hql, string collectionRole, bool shallow,
+ IDictionary<string, IFilter> enabledFilters, ISessionFactoryImplementor factory)
+ :base(hql)
+ {
+ Translators = factory.Settings.QueryTranslatorFactory.CreateQueryTranslators(hql, collectionRole, shallow, enabledFilters, factory);
+
+ BuildSqlStringsAndQuerySpaces();
+
+ if (Translators.Length == 0)
+ {
+ ParameterMetadata = new ParameterMetadata(null, null);
+ ReturnMetadata = null;
+ }
+ else
+ {
+ ParameterMetadata = BuildParameterMetadata(Translators[0].GetParameterTranslations(), hql);
+ if (Translators[0].IsManipulationStatement)
+ {
+ ReturnMetadata = null;
+ }
+ else
+ {
+ if (Translators.Length > 1)
+ {
+ int returns = Translators[0].ReturnTypes.Length;
+ ReturnMetadata = new ReturnMetadata(Translators[0].ReturnAliases, new IType[returns]);
+ }
+ else
+ {
+ ReturnMetadata = new ReturnMetadata(Translators[0].ReturnAliases, Translators[0].ReturnTypes);
+ }
+ }
+ }
+ }
+
+ private static ParameterMetadata BuildParameterMetadata(IParameterTranslations parameterTranslations, string hql)
+ {
+ long start = DateTime.Now.Ticks;
+ ParamLocationRecognizer recognizer = ParamLocationRecognizer.ParseLocations(hql);
+ long end = DateTime.Now.Ticks;
+ if (Log.IsDebugEnabled)
+ {
+ Log.Debug("HQL param location recognition took " + (end - start) + " mills (" + hql + ")");
+ }
+
+ int ordinalParamCount = parameterTranslations.OrdinalParameterCount;
+ int[] locations = recognizer.OrdinalParameterLocationList.ToArray();
+ if (parameterTranslations.SupportsOrdinalParameterMetadata && locations.Length != ordinalParamCount)
+ {
+ throw new HibernateException("ordinal parameter mismatch");
+ }
+ ordinalParamCount = locations.Length;
+ OrdinalParameterDescriptor[] ordinalParamDescriptors = new OrdinalParameterDescriptor[ordinalParamCount];
+ for (int i = 1; i <= ordinalParamCount; i++)
+ {
+ ordinalParamDescriptors[i - 1] =
+ new OrdinalParameterDescriptor(i,
+ parameterTranslations.SupportsOrdinalParameterMetadata
+ ? parameterTranslations.GetOrdinalParameterExpectedType(i)
+ : null, locations[i - 1]);
+ }
+
+ Dictionary<string, NamedParameterDescriptor> namedParamDescriptorMap = new Dictionary<string, NamedParameterDescriptor>();
+ foreach (KeyValuePair<string, ParamLocationRecognizer.NamedParameterDescription> entry in recognizer.NamedParameterDescriptionMap)
+ {
+ string name = entry.Key;
+ ParamLocationRecognizer.NamedParameterDescription description = entry.Value;
+ namedParamDescriptorMap[name] =
+ new NamedParameterDescriptor(name, parameterTranslations.GetNamedParameterExpectedType(name),
+ description.BuildPositionsArray(), description.JpaStyle);
+
+ }
+ return new ParameterMetadata(ordinalParamDescriptors, namedParamDescriptorMap);
+ }
+ }
+
+ [Serializable]
+ public class HQLLinqQueryPlan : HQLQueryPlan, IQueryExpressionPlan
+ {
+ public IQueryExpression QueryExpression
+ {
+ get;
+ protected set;
+ }
+
+ public HQLLinqQueryPlan(string expressionStr, IQueryExpression queryExpression, bool shallow,
+ IDictionary<string, IFilter> enabledFilters, ISessionFactoryImplementor factory)
+ : this(expressionStr, queryExpression, null, shallow, enabledFilters, factory)
+ {
+ }
+
+ protected internal HQLLinqQueryPlan(string expressionStr, IQueryExpression queryExpression, string collectionRole, bool shallow,
+ IDictionary<string, IFilter> enabledFilters, ISessionFactoryImplementor factory)
+ : base (expressionStr)
+ {
+ QueryExpression = queryExpression;
+
+ IQueryTranslatorFactory2 qtFactory = new ASTQueryTranslatorFactory();
+
+ Translators = qtFactory.CreateQueryTranslators(expressionStr, queryExpression, collectionRole, shallow, enabledFilters, factory);
+
+ BuildSqlStringsAndQuerySpaces();
+
+ if (Translators.Length == 0)
+ {
+ ParameterMetadata = new ParameterMetadata(null, null);
+ ReturnMetadata = null;
+ }
+ else
+ {
+ var parameterTranslations = Translators[0].GetParameterTranslations();
+
+ var namedParamDescriptorMap = new Dictionary<string, NamedParameterDescriptor>();
+ foreach (NamedParameterDescriptor entry in queryExpression.ParameterDescriptors)
+ {
+ namedParamDescriptorMap[entry.Name] =
+ new NamedParameterDescriptor(entry.Name, parameterTranslations.GetNamedParameterExpectedType(entry.Name),
+ entry.SourceLocations, entry.JpaStyle);
+ }
+
+ ParameterMetadata = new ParameterMetadata(new OrdinalParameterDescriptor[0], namedParamDescriptorMap);
+
+ if (Translators[0].IsManipulationStatement)
+ {
+ ReturnMetadata = null;
+ }
+ else
+ {
+ if (Translators.Length > 1)
+ {
+ int returns = Translators[0].ReturnTypes.Length;
+ ReturnMetadata = new ReturnMetadata(Translators[0].ReturnAliases, new IType[returns]);
+ }
+ else
+ {
+ ReturnMetadata = new ReturnMetadata(Translators[0].ReturnAliases, Translators[0].ReturnTypes);
+ }
+ }
+ }
+ }
+ }
}
Modified: trunk/nhibernate/src/NHibernate/Engine/Query/QueryPlanCache.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Engine/Query/QueryPlanCache.cs 2009-12-01 21:03:41 UTC (rev 4885)
+++ trunk/nhibernate/src/NHibernate/Engine/Query/QueryPlanCache.cs 2009-12-01 22:08:23 UTC (rev 4886)
@@ -47,10 +47,10 @@
return metadata;
}
- public HQLQueryPlan GetHQLQueryPlan(string queryString, bool shallow, IDictionary<string, IFilter> enabledFilters)
+ public IQueryPlan GetHQLQueryPlan(string queryString, bool shallow, IDictionary<string, IFilter> enabledFilters)
{
var key = new HQLQueryPlanKey(queryString, shallow, enabledFilters);
- var plan = (HQLQueryPlan)planCache[key];
+ var plan = (IQueryPlan)planCache[key];
if (plan == null)
{
@@ -58,7 +58,7 @@
{
log.Debug("unable to locate HQL query plan in cache; generating (" + queryString + ")");
}
- plan = new HQLQueryPlan(queryString, shallow, enabledFilters, factory);
+ plan = new HQLStringQueryPlan(queryString, shallow, enabledFilters, factory);
planCache.Put(key, plan);
}
else
@@ -72,12 +72,12 @@
return plan;
}
- public HQLQueryPlan GetHQLQueryPlan(IQueryExpression queryExpression, bool shallow, IDictionary<string, IFilter> enabledFilters)
+ public IQueryExpressionPlan GetHQLQueryPlan(IQueryExpression queryExpression, bool shallow, IDictionary<string, IFilter> enabledFilters)
{
string expressionStr = queryExpression.Key;
var key = new HQLQueryPlanKey(expressionStr, shallow, enabledFilters);
- var plan = (HQLQueryPlan)planCache[key];
+ var plan = (IQueryExpressionPlan)planCache[key];
if (plan == null)
{
@@ -85,7 +85,7 @@
{
log.Debug("unable to locate HQL query plan in cache; generating (" + expressionStr + ")");
}
- plan = new HQLQueryPlan(expressionStr, queryExpression, shallow, enabledFilters, factory);
+ plan = new HQLLinqQueryPlan(expressionStr, queryExpression, shallow, enabledFilters, factory);
planCache.Put(key, plan);
}
else
Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/ASTQueryTranslatorFactory.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/ASTQueryTranslatorFactory.cs 2009-12-01 21:03:41 UTC (rev 4885)
+++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/ASTQueryTranslatorFactory.cs 2009-12-01 22:08:23 UTC (rev 4886)
@@ -1,5 +1,12 @@
-using System.Collections.Generic;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Antlr.Runtime;
using NHibernate.Engine;
+using NHibernate.Hql.Ast.ANTLR.Tree;
+using NHibernate.Hql.Ast.ANTLR.Util;
+using NHibernate.Hql.Util;
namespace NHibernate.Hql.Ast.ANTLR
{
@@ -12,19 +19,247 @@
/// </summary>
public class ASTQueryTranslatorFactory : IQueryTranslatorFactory2
{
- public IQueryTranslator CreateQueryTranslator(string queryIdentifier, string queryString, IDictionary<string, IFilter> filters, ISessionFactoryImplementor factory)
+ public IQueryTranslator[] CreateQueryTranslators(string queryString, string collectionRole, bool shallow, IDictionary<string, IFilter> filters, ISessionFactoryImplementor factory)
{
- return new QueryTranslatorImpl(queryIdentifier, queryString, filters, factory);
- }
+ var isFilter = collectionRole != null;
+ var parser = new HqlParseEngine(queryString, isFilter, factory);
+ parser.Parse();
- public IFilterTranslator CreateFilterTranslator(string queryIdentifier, string queryString, IDictionary<string, IFilter> filters, ISessionFactoryImplementor factory)
- {
- return new QueryTranslatorImpl(queryIdentifier, queryString, filters, factory);
+ HqlParseEngine[] polymorphicParsers = AstPolymorphicProcessor.Process(parser, factory);
+
+ var translators = polymorphicParsers
+ .Select(hql => new QueryTranslatorImpl(queryString, hql, filters, factory))
+ .ToArray();
+
+ foreach (var translator in translators)
+ {
+ if (collectionRole == null)
+ {
+ translator.Compile(factory.Settings.QuerySubstitutions, shallow);
+ }
+ else
+ {
+ translator.Compile(collectionRole, factory.Settings.QuerySubstitutions, shallow);
+ }
+ }
+
+ return translators;
}
- public IQueryTranslator CreateQueryTranslator(string queryIdentifier, IQueryExpression queryExpression, IDictionary<string, IFilter> filters, ISessionFactoryImplementor factory)
+ public IQueryTranslator[] CreateQueryTranslators(string queryIdentifier, IQueryExpression queryExpression, string collectionRole, bool shallow, IDictionary<string, IFilter> filters, ISessionFactoryImplementor factory)
{
- return new QueryTranslatorImpl(queryIdentifier, queryExpression, filters, factory);
+ var isFilter = collectionRole != null;
+ var parser = new HqlParseEngine(queryExpression.Translate(factory), factory);
+
+ HqlParseEngine[] polymorphicParsers = AstPolymorphicProcessor.Process(parser, factory);
+
+ var translators = polymorphicParsers
+ .Select(hql => new QueryTranslatorImpl(queryIdentifier, hql, filters, factory))
+ .ToArray();
+
+ foreach (var translator in translators)
+ {
+ if (collectionRole == null)
+ {
+ translator.Compile(factory.Settings.QuerySubstitutions, shallow);
+ }
+ else
+ {
+ translator.Compile(collectionRole, factory.Settings.QuerySubstitutions, shallow);
+ }
+ }
+
+ return translators;
}
}
+
+ public class AstPolymorphicProcessor
+ {
+ public static HqlParseEngine[] Process(HqlParseEngine parser, ISessionFactoryImplementor factory)
+ {
+ // Find all the polymorphic "froms"
+ var fromDetector = new FromDetector(factory);
+ var polymorphic = new NodeTraverser(fromDetector);
+ polymorphic.TraverseDepthFirst(parser.Ast);
+
+ if (fromDetector.Map.Count > 0)
+ {
+ var parsers = DuplicateTree(parser.Ast, fromDetector.Map);
+
+ return parsers.Select(p => new HqlParseEngine(p, factory)).ToArray();
+ }
+ else
+ {
+ return new [] { parser };
+ }
+ }
+
+ private static IEnumerable<IASTNode> DuplicateTree(IASTNode ast, IEnumerable<KeyValuePair<IASTNode, IASTNode[]>> nodeMapping)
+ {
+ var replacements = ExpandDictionaryArrays(nodeMapping);
+
+ ...
[truncated message content] |
|
From: <fab...@us...> - 2009-12-02 04:15:52
|
Revision: 4888
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4888&view=rev
Author: fabiomaulo
Date: 2009-12-02 04:15:42 +0000 (Wed, 02 Dec 2009)
Log Message:
-----------
binders refactoring
- ValuePropertyBinder on the road
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/PropertiesBinder.cs
trunk/nhibernate/src/NHibernate/NHibernate.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ValuePropertyBinder.cs
Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/PropertiesBinder.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/PropertiesBinder.cs 2009-12-01 22:52:47 UTC (rev 4887)
+++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/PropertiesBinder.cs 2009-12-02 04:15:42 UTC (rev 4888)
@@ -61,7 +61,7 @@
if ((propertyMapping = entityPropertyMapping as HbmProperty) != null)
{
var value = new SimpleValue(table);
- BindSimpleValue(Serialize(propertyMapping), value, true, propertyName);
+ new ValuePropertyBinder(value, Mappings).BindSimpleValue(propertyMapping, propertyName, true);
property = CreateProperty(entityPropertyMapping, model.ClassName, value, inheritedMetas);
BindValueProperty(propertyMapping, property);
}
Added: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ValuePropertyBinder.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ValuePropertyBinder.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ValuePropertyBinder.cs 2009-12-02 04:15:42 UTC (rev 4888)
@@ -0,0 +1,55 @@
+using System;
+using System.Linq;
+using NHibernate.Cfg.MappingSchema;
+using NHibernate.Mapping;
+using NHibernate.Util;
+
+namespace NHibernate.Cfg.XmlHbmBinding
+{
+ public class ValuePropertyBinder : Binder
+ {
+ private readonly SimpleValue value;
+
+ public ValuePropertyBinder(SimpleValue value, Mappings mappings)
+ : base(mappings)
+ {
+ if (value == null)
+ {
+ throw new ArgumentNullException("value");
+ }
+ this.value = value;
+ }
+
+ //automatically makes a column with the default name if none is specified by XML
+ public void BindSimpleValue(HbmProperty propertyMapping, string propertyPath, bool isNullable)
+ {
+ new TypeBinder(value, Mappings).Bind(propertyMapping.Type);
+ var formulas = propertyMapping.Formulas.ToArray();
+ if (formulas.Length > 0)
+ {
+ foreach (var hbmFormula in formulas)
+ {
+ value.AddFormula(new Formula {FormulaString = hbmFormula.Text.LinesToString()});
+ }
+ }
+ else
+ {
+ new ColumnsBinder(value, Mappings).Bind(propertyMapping.Columns, isNullable,
+ () =>
+ new HbmColumn
+ {
+ name = mappings.NamingStrategy.PropertyToColumnName(propertyPath),
+ length = propertyMapping.length,
+ scale = propertyMapping.scale,
+ precision = propertyMapping.precision,
+ notnull = propertyMapping.notnull,
+ notnullSpecified = propertyMapping.notnullSpecified,
+ unique = propertyMapping.unique,
+ uniqueSpecified = true,
+ uniquekey = propertyMapping.uniquekey,
+ index = propertyMapping.index
+ });
+ }
+ }
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-12-01 22:52:47 UTC (rev 4887)
+++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-12-02 04:15:42 UTC (rev 4888)
@@ -552,6 +552,9 @@
<SubType>Code</SubType>
</Compile>
<Compile Include="Cfg\XmlHbmBinding\TypeBinder.cs" />
+ <Compile Include="Cfg\XmlHbmBinding\ValuePropertyBinder.cs">
+ <SubType>Code</SubType>
+ </Compile>
<Compile Include="Context\WcfOperationSessionContext.cs" />
<Compile Include="Criterion\GroupedProjection.cs" />
<Compile Include="Criterion\IPropertyProjection.cs" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2009-12-02 05:10:32
|
Revision: 4891
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4891&view=rev
Author: fabiomaulo
Date: 2009-12-02 05:10:21 +0000 (Wed, 02 Dec 2009)
Log Message:
-----------
binders refactoring
- minor logging
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassCompositeIdBinder.cs
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassIdBinder.cs
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/CollectionBinder.cs
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/RootClassBinder.cs
trunk/nhibernate/src/NHibernate/NHibernate.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/MappingLogExtensions.cs
Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs 2009-12-02 04:56:46 UTC (rev 4890)
+++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs 2009-12-02 05:10:21 UTC (rev 4891)
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
-using System.Text;
using System.Xml;
using NHibernate.Cfg.MappingSchema;
using NHibernate.Engine;
@@ -511,18 +510,8 @@
"\" for property: " + propName);
}
- if (log.IsDebugEnabled)
- {
- string msg = "Mapped property: " + property.Name;
- string columns = Columns(property.Value);
- if (columns.Length > 0)
- msg += " -> " + columns;
- if (property.Type != null)
- msg += ", type: " + property.Type.Name;
- log.Debug(msg);
- }
-
property.MetaAttributes = GetMetas(node.SelectNodes(HbmConstants.nsMeta, namespaceManager), inheritedMetas);
+ property.LogMapped(log);
}
protected static PropertyGeneration ParsePropertyGeneration(string name)
@@ -538,21 +527,6 @@
}
}
- protected static string Columns(IValue val)
- {
- StringBuilder columns = new StringBuilder();
- bool first = true;
- foreach (ISelectable col in val.ColumnIterator)
- {
- if (first)
- first = false;
- else
- columns.Append(", ");
- columns.Append(col.Text);
- }
- return columns.ToString();
- }
-
//automatically makes a column with the default name if none is specified by XML
protected void BindSimpleValue(XmlNode node, SimpleValue model, bool isNullable, string path)
{
@@ -1078,23 +1052,6 @@
return null;
}
- protected static void LogMappedProperty(Mapping.Property property)
- {
- if (log.IsDebugEnabled)
- {
- string msg = "Mapped property: " + property.Name;
- string columns = Columns(property.Value);
-
- if (columns.Length > 0)
- msg += " -> " + columns;
-
- if (property.Type != null)
- msg += ", type: " + property.Type.Name;
-
- log.Debug(msg);
- }
- }
-
protected static void BindIndex(string indexAttribute, Table table, Column column)
{
if (indexAttribute != null && table != null)
Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassCompositeIdBinder.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassCompositeIdBinder.cs 2009-12-02 04:56:46 UTC (rev 4890)
+++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassCompositeIdBinder.cs 2009-12-02 05:10:21 UTC (rev 4891)
@@ -122,7 +122,7 @@
property.Generation = PropertyGeneration.Never;
property.MetaAttributes = new Dictionary<string, MetaAttribute>();
- LogMappedProperty(property);
+ property.LogMapped(log);
}
private System.Type GetPropertyType(System.Type containingType, string propertyName, HbmCompositeId idSchema)
@@ -212,7 +212,7 @@
property.Generation = PropertyGeneration.Never;
property.MetaAttributes = new Dictionary<string, MetaAttribute>();
- LogMappedProperty(property);
+ property.LogMapped(log);
}
private void BindSimpleValue(HbmKeyProperty keyPropertySchema, SimpleValue model, bool isNullable, string path)
@@ -268,7 +268,7 @@
property.IsOptimisticLocked = true;
property.Generation = PropertyGeneration.Never;
property.MetaAttributes = new Dictionary<string, MetaAttribute>();
- LogMappedProperty(property);
+ property.LogMapped(log);
}
}
}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassIdBinder.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassIdBinder.cs 2009-12-02 04:56:46 UTC (rev 4890)
+++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassIdBinder.cs 2009-12-02 05:10:21 UTC (rev 4891)
@@ -60,7 +60,7 @@
rootClass.IdentifierProperty = property;
- LogMappedProperty(property);
+ property.LogMapped(log);
}
}
Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/CollectionBinder.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/CollectionBinder.cs 2009-12-02 04:56:46 UTC (rev 4890)
+++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/CollectionBinder.cs 2009-12-02 05:10:21 UTC (rev 4891)
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Linq;
using System.Xml;
using NHibernate.Mapping;
@@ -479,14 +480,14 @@
if (log.IsDebugEnabled)
{
- string msg = "Mapped collection key: " + Columns(collection.Key);
+ string msg = "Mapped collection key: " + string.Join(",", collection.Key.ColumnIterator.Select(c => c.Text).ToArray());
if (collection.IsIndexed)
- msg += ", index: " + Columns(((IndexedCollection)collection).Index);
+ msg += ", index: " + string.Join(",", ((IndexedCollection)collection).Index.ColumnIterator.Select(c => c.Text).ToArray());
if (collection.IsOneToMany)
msg += ", one-to-many: " + collection.Element.Type.Name;
else
{
- msg += ", element: " + Columns(collection.Element);
+ msg += ", element: " + string.Join(",", collection.Element.ColumnIterator.Select(c => c.Text).ToArray());
msg += ", type: " + collection.Element.Type.Name;
}
log.Debug(msg);
Added: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/MappingLogExtensions.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/MappingLogExtensions.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/MappingLogExtensions.cs 2009-12-02 05:10:21 UTC (rev 4891)
@@ -0,0 +1,22 @@
+using System.Linq;
+using log4net;
+
+namespace NHibernate.Cfg.XmlHbmBinding
+{
+ public static class MappingLogExtensions
+ {
+ public static void LogMapped(this Mapping.Property property, ILog log)
+ {
+ if (log.IsDebugEnabled)
+ {
+ string msg = "Mapped property: " + property.Name;
+ string columns = string.Join(",", property.Value.ColumnIterator.Select(c => c.Text).ToArray());
+ if (columns.Length > 0)
+ msg += " -> " + columns;
+ if (property.Type != null)
+ msg += ", type: " + property.Type.Name;
+ log.Debug(msg);
+ }
+ }
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/RootClassBinder.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/RootClassBinder.cs 2009-12-02 04:56:46 UTC (rev 4890)
+++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/RootClassBinder.cs 2009-12-02 05:10:21 UTC (rev 4891)
@@ -172,7 +172,7 @@
property.MetaAttributes = GetMetas(timestampSchema, inheritedMetas);
- LogMappedProperty(property);
+ property.LogMapped(log);
}
private static PropertyGeneration Convert(HbmVersionGeneration versionGeneration)
@@ -253,7 +253,7 @@
property.MetaAttributes = GetMetas(versionSchema, inheritedMetas);
- LogMappedProperty(property);
+ property.LogMapped(log);
}
private static void BindCache(HbmCache cacheSchema, RootClass rootClass)
Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-12-02 04:56:46 UTC (rev 4890)
+++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-12-02 05:10:21 UTC (rev 4891)
@@ -548,6 +548,7 @@
<Compile Include="Cfg\MappingSchema\IDecoratable.cs" />
<Compile Include="Cfg\XmlHbmBinding\ColumnsBinder.cs" />
<Compile Include="Cfg\XmlHbmBinding\FiltersBinder.cs" />
+ <Compile Include="Cfg\XmlHbmBinding\MappingLogExtensions.cs" />
<Compile Include="Cfg\XmlHbmBinding\PropertiesBinder.cs">
<SubType>Code</SubType>
</Compile>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ste...@us...> - 2009-12-02 15:07:25
|
Revision: 4893
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4893&view=rev
Author: steverstrong
Date: 2009-12-02 15:07:16 +0000 (Wed, 02 Dec 2009)
Log Message:
-----------
Refactoring of HQLQueryPlan changes
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Engine/Query/HQLQueryPlan.cs
trunk/nhibernate/src/NHibernate/Engine/Query/QueryPlanCache.cs
trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/ASTQueryTranslatorFactory.cs
trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QueryTranslatorImpl.cs
trunk/nhibernate/src/NHibernate/Hql/Classic/ClassicQueryTranslatorFactory.cs
trunk/nhibernate/src/NHibernate/Hql/Classic/QueryTranslator.cs
trunk/nhibernate/src/NHibernate/Hql/IQueryTranslator.cs
trunk/nhibernate/src/NHibernate/NHibernate.csproj
trunk/nhibernate/src/NHibernate.Test/BulkManipulation/BaseFixture.cs
trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BaseFixture.cs
Added Paths:
-----------
trunk/nhibernate/src/NHibernate/Engine/Query/HQLExpressionQueryPlan.cs
trunk/nhibernate/src/NHibernate/Engine/Query/HQLStringQueryPlan.cs
trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/AstPolymorphicProcessor.cs
trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/CrossJoinDictionaryArrays.cs
trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/PolymorphicQuerySourceDetector.cs
trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QuerySourceDetector.cs
Added: trunk/nhibernate/src/NHibernate/Engine/Query/HQLExpressionQueryPlan.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Engine/Query/HQLExpressionQueryPlan.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Engine/Query/HQLExpressionQueryPlan.cs 2009-12-02 15:07:16 UTC (rev 4893)
@@ -0,0 +1,37 @@
+using System;
+using System.Collections.Generic;
+using NHibernate.Hql;
+using NHibernate.Hql.Ast.ANTLR;
+
+namespace NHibernate.Engine.Query
+{
+ [Serializable]
+ public class HQLExpressionQueryPlan : HQLQueryPlan, IQueryExpressionPlan
+ {
+ public IQueryExpression QueryExpression
+ {
+ get;
+ protected set;
+ }
+
+ public HQLExpressionQueryPlan(string expressionStr, IQueryExpression queryExpression, bool shallow,
+ IDictionary<string, IFilter> enabledFilters, ISessionFactoryImplementor factory)
+ : this(expressionStr, queryExpression, null, shallow, enabledFilters, factory)
+ {
+ }
+
+ protected internal HQLExpressionQueryPlan(string expressionStr, IQueryExpression queryExpression, string collectionRole, bool shallow,
+ IDictionary<string, IFilter> enabledFilters, ISessionFactoryImplementor factory)
+ : base(expressionStr, CreateTranslators(expressionStr, queryExpression, collectionRole, shallow, enabledFilters, factory))
+ {
+ QueryExpression = queryExpression;
+ }
+
+ private static IQueryTranslator[] CreateTranslators(string expressionStr, IQueryExpression queryExpression, string collectionRole, bool shallow, IDictionary<string, IFilter> enabledFilters, ISessionFactoryImplementor factory)
+ {
+ IQueryTranslatorFactory2 qtFactory = new ASTQueryTranslatorFactory();
+
+ return qtFactory.CreateQueryTranslators(expressionStr, queryExpression, collectionRole, shallow, enabledFilters, factory);
+ }
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Engine/Query/HQLQueryPlan.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Engine/Query/HQLQueryPlan.cs 2009-12-02 05:30:33 UTC (rev 4892)
+++ trunk/nhibernate/src/NHibernate/Engine/Query/HQLQueryPlan.cs 2009-12-02 15:07:16 UTC (rev 4893)
@@ -1,13 +1,10 @@
using System;
using System.Collections;
using System.Collections.Generic;
-using Iesi.Collections;
using Iesi.Collections.Generic;
using log4net;
using NHibernate.Event;
using NHibernate.Hql;
-using NHibernate.Hql.Ast.ANTLR;
-using NHibernate.Impl;
using NHibernate.Type;
using NHibernate.Util;
@@ -38,39 +35,42 @@
private readonly string _sourceQuery;
- protected HQLQueryPlan(string sourceQuery)
+ protected HQLQueryPlan(string sourceQuery, IQueryTranslator[] translators)
{
+ Translators = translators;
_sourceQuery = sourceQuery;
+
+ FinaliseQueryPlan();
}
- public ISet<string> QuerySpaces
+ public ISet<string> QuerySpaces
{
get;
- protected set;
+ private set;
}
public ParameterMetadata ParameterMetadata
{
get;
- protected set;
+ private set;
}
public ReturnMetadata ReturnMetadata
{
get;
- protected set;
+ private set;
}
public string[] SqlStrings
{
get;
- protected set;
+ private set;
}
public IQueryTranslator[] Translators
{
get;
- protected set;
+ private set;
}
public void PerformList(QueryParameters queryParameters, ISessionImplementor session, IList results)
@@ -156,8 +156,26 @@
return new SafetyEnumerable<T>(PerformIterate(queryParameters, session));
}
- private void DoIterate(QueryParameters queryParameters, IEventSource session, out bool? isMany,
- out IEnumerable[] results, out IEnumerable result)
+ public int PerformExecuteUpdate(QueryParameters queryParameters, ISessionImplementor session)
+ {
+ if (Log.IsDebugEnabled)
+ {
+ Log.Debug("executeUpdate: " + _sourceQuery);
+ queryParameters.LogParameters(session.Factory);
+ }
+ if (Translators.Length != 1)
+ {
+ Log.Warn("manipulation query [" + _sourceQuery + "] resulted in [" + Translators.Length + "] split queries");
+ }
+ int result = 0;
+ for (int i = 0; i < Translators.Length; i++)
+ {
+ result += Translators[i].ExecuteUpdate(queryParameters, session);
+ }
+ return result;
+ }
+
+ void DoIterate(QueryParameters queryParameters, IEventSource session, out bool? isMany, out IEnumerable[] results, out IEnumerable result)
{
isMany = null;
results = null;
@@ -190,176 +208,23 @@
}
}
- public int PerformExecuteUpdate(QueryParameters queryParameters, ISessionImplementor session)
- {
- if (Log.IsDebugEnabled)
- {
- Log.Debug("executeUpdate: " + _sourceQuery);
- queryParameters.LogParameters(session.Factory);
- }
- if (Translators.Length != 1)
- {
- Log.Warn("manipulation query [" + _sourceQuery + "] resulted in [" + Translators.Length + "] split queries");
- }
- int result = 0;
- for (int i = 0; i < Translators.Length; i++)
- {
- result += Translators[i].ExecuteUpdate(queryParameters, session);
- }
- return result;
- }
-
- protected void BuildSqlStringsAndQuerySpaces()
+ void FinaliseQueryPlan()
{
- var combinedQuerySpaces = new HashedSet<string>();
- var sqlStringList = new List<string>();
-
- foreach (var translator in Translators)
- {
- foreach (var qs in translator.QuerySpaces)
- {
- combinedQuerySpaces.Add(qs);
- }
-
- sqlStringList.AddRange(translator.CollectSqlStrings);
- }
-
- SqlStrings = sqlStringList.ToArray();
- QuerySpaces = combinedQuerySpaces;
+ BuildSqlStringsAndQuerySpaces();
+ BuildMetaData();
}
- }
- [Serializable]
- public class HQLStringQueryPlan : HQLQueryPlan
- {
- public HQLStringQueryPlan(string hql, bool shallow,
- IDictionary<string, IFilter> enabledFilters, ISessionFactoryImplementor factory)
- : this(hql, (string) null, shallow, enabledFilters, factory)
- {
- }
-
- protected internal HQLStringQueryPlan(string hql, string collectionRole, bool shallow,
- IDictionary<string, IFilter> enabledFilters, ISessionFactoryImplementor factory)
- :base(hql)
- {
- Translators = factory.Settings.QueryTranslatorFactory.CreateQueryTranslators(hql, collectionRole, shallow, enabledFilters, factory);
-
- BuildSqlStringsAndQuerySpaces();
-
+ void BuildMetaData()
+ {
if (Translators.Length == 0)
- {
- ParameterMetadata = new ParameterMetadata(null, null);
- ReturnMetadata = null;
- }
- else
- {
- ParameterMetadata = BuildParameterMetadata(Translators[0].GetParameterTranslations(), hql);
- if (Translators[0].IsManipulationStatement)
- {
- ReturnMetadata = null;
- }
- else
- {
- if (Translators.Length > 1)
- {
- int returns = Translators[0].ReturnTypes.Length;
- ReturnMetadata = new ReturnMetadata(Translators[0].ReturnAliases, new IType[returns]);
- }
- else
- {
- ReturnMetadata = new ReturnMetadata(Translators[0].ReturnAliases, Translators[0].ReturnTypes);
- }
- }
- }
- }
-
- private static ParameterMetadata BuildParameterMetadata(IParameterTranslations parameterTranslations, string hql)
- {
- long start = DateTime.Now.Ticks;
- ParamLocationRecognizer recognizer = ParamLocationRecognizer.ParseLocations(hql);
- long end = DateTime.Now.Ticks;
- if (Log.IsDebugEnabled)
{
- Log.Debug("HQL param location recognition took " + (end - start) + " mills (" + hql + ")");
- }
-
- int ordinalParamCount = parameterTranslations.OrdinalParameterCount;
- int[] locations = recognizer.OrdinalParameterLocationList.ToArray();
- if (parameterTranslations.SupportsOrdinalParameterMetadata && locations.Length != ordinalParamCount)
- {
- throw new HibernateException("ordinal parameter mismatch");
- }
- ordinalParamCount = locations.Length;
- OrdinalParameterDescriptor[] ordinalParamDescriptors = new OrdinalParameterDescriptor[ordinalParamCount];
- for (int i = 1; i <= ordinalParamCount; i++)
- {
- ordinalParamDescriptors[i - 1] =
- new OrdinalParameterDescriptor(i,
- parameterTranslations.SupportsOrdinalParameterMetadata
- ? parameterTranslations.GetOrdinalParameterExpectedType(i)
- : null, locations[i - 1]);
- }
-
- Dictionary<string, NamedParameterDescriptor> namedParamDescriptorMap = new Dictionary<string, NamedParameterDescriptor>();
- foreach (KeyValuePair<string, ParamLocationRecognizer.NamedParameterDescription> entry in recognizer.NamedParameterDescriptionMap)
- {
- string name = entry.Key;
- ParamLocationRecognizer.NamedParameterDescription description = entry.Value;
- namedParamDescriptorMap[name] =
- new NamedParameterDescriptor(name, parameterTranslations.GetNamedParameterExpectedType(name),
- description.BuildPositionsArray(), description.JpaStyle);
-
- }
- return new ParameterMetadata(ordinalParamDescriptors, namedParamDescriptorMap);
- }
- }
-
- [Serializable]
- public class HQLLinqQueryPlan : HQLQueryPlan, IQueryExpressionPlan
- {
- public IQueryExpression QueryExpression
- {
- get;
- protected set;
- }
-
- public HQLLinqQueryPlan(string expressionStr, IQueryExpression queryExpression, bool shallow,
- IDictionary<string, IFilter> enabledFilters, ISessionFactoryImplementor factory)
- : this(expressionStr, queryExpression, null, shallow, enabledFilters, factory)
- {
- }
-
- protected internal HQLLinqQueryPlan(string expressionStr, IQueryExpression queryExpression, string collectionRole, bool shallow,
- IDictionary<string, IFilter> enabledFilters, ISessionFactoryImplementor factory)
- : base (expressionStr)
- {
- QueryExpression = queryExpression;
-
- IQueryTranslatorFactory2 qtFactory = new ASTQueryTranslatorFactory();
-
- Translators = qtFactory.CreateQueryTranslators(expressionStr, queryExpression, collectionRole, shallow, enabledFilters, factory);
-
- BuildSqlStringsAndQuerySpaces();
-
- if (Translators.Length == 0)
- {
ParameterMetadata = new ParameterMetadata(null, null);
ReturnMetadata = null;
}
else
{
- var parameterTranslations = Translators[0].GetParameterTranslations();
+ ParameterMetadata = Translators[0].BuildParameterMetadata();
- var namedParamDescriptorMap = new Dictionary<string, NamedParameterDescriptor>();
- foreach (NamedParameterDescriptor entry in queryExpression.ParameterDescriptors)
- {
- namedParamDescriptorMap[entry.Name] =
- new NamedParameterDescriptor(entry.Name, parameterTranslations.GetNamedParameterExpectedType(entry.Name),
- entry.SourceLocations, entry.JpaStyle);
- }
-
- ParameterMetadata = new ParameterMetadata(new OrdinalParameterDescriptor[0], namedParamDescriptorMap);
-
if (Translators[0].IsManipulationStatement)
{
ReturnMetadata = null;
@@ -378,5 +243,24 @@
}
}
}
+
+ void BuildSqlStringsAndQuerySpaces()
+ {
+ var combinedQuerySpaces = new HashedSet<string>();
+ var sqlStringList = new List<string>();
+
+ foreach (var translator in Translators)
+ {
+ foreach (var qs in translator.QuerySpaces)
+ {
+ combinedQuerySpaces.Add(qs);
+ }
+
+ sqlStringList.AddRange(translator.CollectSqlStrings);
+ }
+
+ SqlStrings = sqlStringList.ToArray();
+ QuerySpaces = combinedQuerySpaces;
+ }
}
}
Added: trunk/nhibernate/src/NHibernate/Engine/Query/HQLStringQueryPlan.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Engine/Query/HQLStringQueryPlan.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Engine/Query/HQLStringQueryPlan.cs 2009-12-02 15:07:16 UTC (rev 4893)
@@ -0,0 +1,27 @@
+using System;
+using System.Collections.Generic;
+using NHibernate.Hql;
+
+namespace NHibernate.Engine.Query
+{
+ [Serializable]
+ public class HQLStringQueryPlan : HQLQueryPlan
+ {
+ public HQLStringQueryPlan(string hql, bool shallow,
+ IDictionary<string, IFilter> enabledFilters, ISessionFactoryImplementor factory)
+ : this(hql, (string) null, shallow, enabledFilters, factory)
+ {
+ }
+
+ protected internal HQLStringQueryPlan(string hql, string collectionRole, bool shallow,
+ IDictionary<string, IFilter> enabledFilters, ISessionFactoryImplementor factory)
+ : base(hql, CreateTranslators(hql, collectionRole, shallow, enabledFilters, factory))
+ {
+ }
+
+ private static IQueryTranslator[] CreateTranslators(string hql, string collectionRole, bool shallow, IDictionary<string, IFilter> enabledFilters, ISessionFactoryImplementor factory)
+ {
+ return factory.Settings.QueryTranslatorFactory.CreateQueryTranslators(hql, collectionRole, shallow, enabledFilters, factory);
+ }
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Engine/Query/QueryPlanCache.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Engine/Query/QueryPlanCache.cs 2009-12-02 05:30:33 UTC (rev 4892)
+++ trunk/nhibernate/src/NHibernate/Engine/Query/QueryPlanCache.cs 2009-12-02 15:07:16 UTC (rev 4893)
@@ -85,7 +85,7 @@
{
log.Debug("unable to locate HQL query plan in cache; generating (" + expressionStr + ")");
}
- plan = new HQLLinqQueryPlan(expressionStr, queryExpression, shallow, enabledFilters, factory);
+ plan = new HQLExpressionQueryPlan(expressionStr, queryExpression, shallow, enabledFilters, factory);
planCache.Put(key, plan);
}
else
Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/ASTQueryTranslatorFactory.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/ASTQueryTranslatorFactory.cs 2009-12-02 05:30:33 UTC (rev 4892)
+++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/ASTQueryTranslatorFactory.cs 2009-12-02 15:07:16 UTC (rev 4893)
@@ -1,12 +1,7 @@
-using System;
-using System.Collections.Generic;
+using System.Collections.Generic;
using System.Linq;
-using System.Text;
-using Antlr.Runtime;
using NHibernate.Engine;
using NHibernate.Hql.Ast.ANTLR.Tree;
-using NHibernate.Hql.Ast.ANTLR.Util;
-using NHibernate.Hql.Util;
namespace NHibernate.Hql.Ast.ANTLR
{
@@ -21,37 +16,21 @@
{
public IQueryTranslator[] CreateQueryTranslators(string queryString, string collectionRole, bool shallow, IDictionary<string, IFilter> filters, ISessionFactoryImplementor factory)
{
- var isFilter = collectionRole != null;
- var parser = new HqlParseEngine(queryString, isFilter, factory);
- parser.Parse();
+ var ast = new HqlParseEngine(queryString, collectionRole != null, factory).Parse();
- HqlParseEngine[] polymorphicParsers = AstPolymorphicProcessor.Process(parser, factory);
+ return CreateQueryTranslators(ast, queryString, collectionRole, shallow,
+ filters, factory);
+ }
- var translators = polymorphicParsers
- .Select(hql => new QueryTranslatorImpl(queryString, hql, filters, factory))
- .ToArray();
-
- foreach (var translator in translators)
- {
- if (collectionRole == null)
- {
- translator.Compile(factory.Settings.QuerySubstitutions, shallow);
- }
- else
- {
- translator.Compile(collectionRole, factory.Settings.QuerySubstitutions, shallow);
- }
- }
-
- return translators;
- }
-
public IQueryTranslator[] CreateQueryTranslators(string queryIdentifier, IQueryExpression queryExpression, string collectionRole, bool shallow, IDictionary<string, IFilter> filters, ISessionFactoryImplementor factory)
{
- var isFilter = collectionRole != null;
- var parser = new HqlParseEngine(queryExpression.Translate(factory), factory);
+ return CreateQueryTranslators(queryExpression.Translate(factory), queryIdentifier, collectionRole, shallow,
+ filters, factory);
+ }
- HqlParseEngine[] polymorphicParsers = AstPolymorphicProcessor.Process(parser, factory);
+ static IQueryTranslator[] CreateQueryTranslators(IASTNode ast, string queryIdentifier, string collectionRole, bool shallow, IDictionary<string, IFilter> filters, ISessionFactoryImplementor factory)
+ {
+ var polymorphicParsers = AstPolymorphicProcessor.Process(ast, factory);
var translators = polymorphicParsers
.Select(hql => new QueryTranslatorImpl(queryIdentifier, hql, filters, factory))
@@ -70,196 +49,7 @@
}
return translators;
+
}
}
-
- public class AstPolymorphicProcessor
- {
- public static HqlParseEngine[] Process(HqlParseEngine parser, ISessionFactoryImplementor factory)
- {
- // Find all the polymorphic "froms"
- var fromDetector = new FromDetector(factory);
- var polymorphic = new NodeTraverser(fromDetector);
- polymorphic.TraverseDepthFirst(parser.Ast);
-
- if (fromDetector.Map.Count > 0)
- {
- var parsers = DuplicateTree(parser.Ast, fromDetector.Map);
-
- return parsers.Select(p => new HqlParseEngine(p, factory)).ToArray();
- }
- else
- {
- return new [] { parser };
- }
- }
-
- private static IEnumerable<IASTNode> DuplicateTree(IASTNode ast, IEnumerable<KeyValuePair<IASTNode, IASTNode[]>> nodeMapping)
- {
- var replacements = ExpandDictionaryArrays(nodeMapping);
-
- var dups = new IASTNode[replacements.Count()];
-
- for (var i = 0; i < replacements.Count(); i++)
- {
- dups[i] = DuplicateTree(ast, replacements[i]);
- }
-
- return dups;
- }
-
- private static IASTNode DuplicateTree(IASTNode ast, Dictionary<IASTNode, IASTNode> nodeMapping)
- {
- IASTNode candidate;
-
- if (nodeMapping.TryGetValue(ast, out candidate))
- {
- return candidate;
- }
-
- var dup = ast.DupNode();
-
- foreach (var child in ast)
- {
- dup.AddChild(DuplicateTree(child, nodeMapping));
- }
-
- return dup;
- }
-
- static IList<Dictionary<IASTNode, IASTNode>> ExpandDictionaryArrays(IEnumerable<KeyValuePair<IASTNode, IASTNode[]>> input)
- {
- return (from list in ExpandDictionaryArraysInner(input)
- select list.ToDictionary(kvp => kvp.Key, kvp => kvp.Value)).ToList();
- }
-
- static IEnumerable<IEnumerable<KeyValuePair<IASTNode, IASTNode>>> ExpandDictionaryArraysInner(IEnumerable<KeyValuePair<IASTNode, IASTNode[]>> input)
- {
- var output = new List<IEnumerable<KeyValuePair<IASTNode, IASTNode>>>();
-
- foreach (var value in input.First().Value)
- {
- var inner = new List<KeyValuePair<IASTNode, IASTNode>>
- {new KeyValuePair<IASTNode, IASTNode>(input.First().Key, value)};
-
- if (input.Count() > 1)
- {
- output.AddRange(ExpandDictionaryArraysInner(input.Skip(1)).Select(c => c.Union(inner)));
- }
- else
- {
- output.Add(inner);
- }
- }
-
- return output;
- }
-
- }
-
-
- internal class FromDetector : IVisitationStrategy
- {
- private readonly ISessionFactoryImplementor _sfi;
- private readonly Dictionary<IASTNode, IASTNode[]> _map = new Dictionary<IASTNode, IASTNode[]>();
-
- public FromDetector(ISessionFactoryImplementor sfi)
- {
- _sfi = sfi;
- }
-
- public IDictionary<IASTNode, IASTNode[]> Map
- {
- get { return _map; }
- }
-
- public void Visit(IASTNode node)
- {
- if (node.Type == HqlSqlWalker.FROM && node.ChildCount > 0)
- {
- foreach (var child in node)
- {
- string className = null;
- IASTNode identifer = null;
-
- if (child.Type == HqlSqlWalker.RANGE)
- {
- identifer = child.GetChild(0);
-
- if (identifer.Type == HqlSqlWalker.IDENT)
- {
- className = identifer.Text;
- }
- else if (identifer.Type == HqlSqlWalker.DOT)
- {
- className = BuildPath(identifer);
- }
- else
- {
- // TODO
- throw new NotSupportedException();
- }
- }
- else
- {
- // TODO - stuff for joins?
- }
-
- if (className != null)
- {
- System.Type classType = (new SessionFactoryHelper(_sfi)).GetImportedClass(className);
-
- if (classType != null)
- {
- string[] implementors = _sfi.GetImplementors(classType.FullName);
-
- if (implementors != null)
- {
- if (implementors.Length == 1 &&
- ((implementors[0] == className) || (implementors[0] == classType.FullName)))
- {
- // No need to change things
- return;
- }
-
- Map.Add(identifer,
- implementors.Select(implementor => MakeIdent(identifer, implementor)).ToArray());
- }
- }
- }
- }
- }
- }
-
- private IASTNode MakeIdent(IASTNode source, string text)
- {
- var ident = source.DupNode();
- ident.Type = HqlSqlWalker.IDENT;
- ident.Text = text;
- return ident;
- }
-
- private static string BuildPath(IASTNode node)
- {
- var sb = new StringBuilder();
- BuildPath(node, sb);
- return sb.ToString();
- }
-
- private static void BuildPath(IASTNode node, StringBuilder sb)
- {
- if (node.Type == HqlSqlWalker.DOT)
- {
- BuildPath(node.GetChild(0), sb);
-
- sb.Append('.');
- sb.Append(node.GetChild(1).Text);
- }
- else
- {
- sb.Append(node.Text);
- }
- }
- }
-
}
Added: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/AstPolymorphicProcessor.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/AstPolymorphicProcessor.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/AstPolymorphicProcessor.cs 2009-12-02 15:07:16 UTC (rev 4893)
@@ -0,0 +1,75 @@
+using System.Collections.Generic;
+using System.Linq;
+using NHibernate.Engine;
+using NHibernate.Hql.Ast.ANTLR.Tree;
+
+namespace NHibernate.Hql.Ast.ANTLR
+{
+ public class AstPolymorphicProcessor
+ {
+ private readonly IASTNode _ast;
+ private readonly ISessionFactoryImplementor _factory;
+ private IEnumerable<KeyValuePair<IASTNode, IASTNode[]>> _nodeMapping;
+
+ private AstPolymorphicProcessor(IASTNode ast, ISessionFactoryImplementor factory)
+ {
+ _ast = ast;
+ _factory = factory;
+ }
+
+ public static IASTNode[] Process(IASTNode ast, ISessionFactoryImplementor factory)
+ {
+ var processor = new AstPolymorphicProcessor(ast, factory);
+
+ return processor.Process();
+ }
+
+ private IASTNode[] Process()
+ {
+ // Find all the polymorphic query sources
+ _nodeMapping = new PolymorphicQuerySourceDetector(_factory).Process(_ast);
+
+ if (_nodeMapping.Count() > 0)
+ {
+ return DuplicateTree().ToArray();
+ }
+ else
+ {
+ return new[] { _ast };
+ }
+ }
+
+ private IEnumerable<IASTNode> DuplicateTree()
+ {
+ var replacements = CrossJoinDictionaryArrays.PerformCrossJoin(_nodeMapping);
+
+ var dups = new IASTNode[replacements.Count()];
+
+ for (var i = 0; i < replacements.Count(); i++)
+ {
+ dups[i] = DuplicateTree(_ast, replacements[i]);
+ }
+
+ return dups;
+ }
+
+ private static IASTNode DuplicateTree(IASTNode ast, IDictionary<IASTNode, IASTNode> nodeMapping)
+ {
+ IASTNode candidate;
+
+ if (nodeMapping.TryGetValue(ast, out candidate))
+ {
+ return candidate;
+ }
+
+ var dup = ast.DupNode();
+
+ foreach (var child in ast)
+ {
+ dup.AddChild(DuplicateTree(child, nodeMapping));
+ }
+
+ return dup;
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/CrossJoinDictionaryArrays.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/CrossJoinDictionaryArrays.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/CrossJoinDictionaryArrays.cs 2009-12-02 15:07:16 UTC (rev 4893)
@@ -0,0 +1,33 @@
+using System.Collections.Generic;
+using System.Linq;
+using NHibernate.Hql.Ast.ANTLR.Tree;
+
+namespace NHibernate.Hql.Ast.ANTLR
+{
+ public static class CrossJoinDictionaryArrays
+ {
+ public static IList<Dictionary<IASTNode, IASTNode>> PerformCrossJoin(IEnumerable<KeyValuePair<IASTNode, IASTNode[]>> input)
+ {
+ return (from list in CrossJoinKeyValuePairList(input)
+ select list.ToDictionary(kvp => kvp.Key, kvp => kvp.Value)).ToList();
+ }
+
+ static IEnumerable<IEnumerable<KeyValuePair<IASTNode, IASTNode>>> CrossJoinKeyVa...
[truncated message content] |
|
From: <ric...@us...> - 2009-12-05 22:14:16
|
Revision: 4894
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4894&view=rev
Author: ricbrown
Date: 2009-12-05 22:14:08 +0000 (Sat, 05 Dec 2009)
Log Message:
-----------
Fix NH-2030 (Thread unsafe method in SqlTypeFactory)
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/SqlTypes/SqlTypeFactory.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2030/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2030/Fixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2030/Mappings.hbm.xml
Modified: trunk/nhibernate/src/NHibernate/SqlTypes/SqlTypeFactory.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/SqlTypes/SqlTypeFactory.cs 2009-12-02 15:07:16 UTC (rev 4893)
+++ trunk/nhibernate/src/NHibernate/SqlTypes/SqlTypeFactory.cs 2009-12-05 22:14:08 UTC (rev 4894)
@@ -47,8 +47,14 @@
SqlType result;
if (!SqlTypes.TryGetValue(key, out result))
{
- result = createDelegate(length);
- SqlTypes.Add(key, result);
+ lock(SqlTypes)
+ {
+ if (!SqlTypes.TryGetValue(key, out result))
+ {
+ result = createDelegate(length);
+ SqlTypes.Add(key, result);
+ }
+ }
}
return (T) result;
}
Property changes on: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2030
___________________________________________________________________
Added: bugtraq:url
+ http://jira.nhibernate.org/browse/%BUGID%
Added: bugtraq:logregex
+ NH-\d+
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2030/Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2030/Fixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2030/Fixture.cs 2009-12-05 22:14:08 UTC (rev 4894)
@@ -0,0 +1,66 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Text;
+using System.Threading;
+using NHibernate.Dialect;
+using NHibernate.SqlTypes;
+using NUnit.Framework;
+
+namespace NHibernate.Test.NHSpecificTest.NH2030
+{
+ [TestFixture]
+ public class Fixture : BugTestCase
+ {
+
+ [Test]
+ public void GetTypeWithLenShouldBeThreadSafe()
+ {
+ object sync = new object();
+ List<Exception> exceptions = new List<Exception>();
+
+ ManualResetEvent startEvent = new ManualResetEvent(false);
+ var action = new ThreadStart
+ (() =>
+ {
+ startEvent.WaitOne();
+ try
+ {
+ for (int i = 0; i < 1000; i++)
+ {
+ SqlTypeFactory.GetString(i);
+ }
+ }
+ catch (Exception e)
+ {
+ lock (sync)
+ {
+ exceptions.Add(e);
+ }
+ }
+ });
+
+ const int threadCount = 30;
+ Thread[] threads = new Thread[threadCount];
+ for (int i = 0; i < threadCount; i++)
+ {
+ threads[i] = new Thread(action);
+ threads[i].Start();
+ }
+ startEvent.Set();
+ foreach (var thread in threads)
+ {
+ thread.Join();
+ }
+
+ if(exceptions.Count > 0)
+ {
+ foreach(var e in exceptions)
+ Console.WriteLine(e);
+
+ throw exceptions[0];
+ }
+
+ }
+ }
+}
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2030/Mappings.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2030/Mappings.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2030/Mappings.hbm.xml 2009-12-05 22:14:08 UTC (rev 4894)
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ assembly="NHibernate.Test"
+ namespace="NHibernate.Test.NHSpecificTest.NH2030">
+</hibernate-mapping>
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-12-02 15:07:16 UTC (rev 4893)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-12-05 22:14:08 UTC (rev 4894)
@@ -674,6 +674,7 @@
<Compile Include="NHSpecificTest\NH2003\Model.cs" />
<Compile Include="NHSpecificTest\NH2011\Fixture.cs" />
<Compile Include="NHSpecificTest\NH2011\Model.cs" />
+ <Compile Include="NHSpecificTest\NH2030\Fixture.cs" />
<Compile Include="NHSpecificTest\NH473\Child.cs" />
<Compile Include="NHSpecificTest\NH473\Fixture.cs" />
<Compile Include="NHSpecificTest\NH473\Parent.cs" />
@@ -2087,6 +2088,7 @@
<EmbeddedResource Include="CfgTest\Loquacious\EntityToCache.hbm.xml" />
<EmbeddedResource Include="DriverTest\SqlServerCeEntity.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="NHSpecificTest\NH2030\Mappings.hbm.xml" />
<EmbeddedResource Include="Linq\Mappings\Patient.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH2011\Mappings.hbm.xml" />
<EmbeddedResource Include="Linq\Mappings\Animal.hbm.xml" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ste...@us...> - 2009-12-16 21:36:52
|
Revision: 4895
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4895&view=rev
Author: steverstrong
Date: 2009-12-16 21:36:34 +0000 (Wed, 16 Dec 2009)
Log Message:
-----------
More Linq test cases and supporting fixes.
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/PolymorphicQuerySourceDetector.cs
trunk/nhibernate/src/NHibernate/Hql/Ast/HqlTreeBuilder.cs
trunk/nhibernate/src/NHibernate/Hql/Ast/HqlTreeNode.cs
trunk/nhibernate/src/NHibernate/Impl/AbstractQueryImpl.cs
trunk/nhibernate/src/NHibernate/Impl/ExpressionQueryImpl.cs
trunk/nhibernate/src/NHibernate/Linq/ExpressionToHqlTranslationResults.cs
trunk/nhibernate/src/NHibernate/Linq/Expressions/NhExpressionType.cs
trunk/nhibernate/src/NHibernate/Linq/Expressions/NhNewExpression.cs
trunk/nhibernate/src/NHibernate/Linq/Functions/BaseHqlGeneratorForType.cs
trunk/nhibernate/src/NHibernate/Linq/Functions/FunctionRegistry.cs
trunk/nhibernate/src/NHibernate/Linq/Functions/IHqlGeneratorForType.cs
trunk/nhibernate/src/NHibernate/Linq/Functions/QueryableGenerator.cs
trunk/nhibernate/src/NHibernate/Linq/LinqExtensionMethods.cs
trunk/nhibernate/src/NHibernate/Linq/NhLinqExpression.cs
trunk/nhibernate/src/NHibernate/Linq/NhQueryProvider.cs
trunk/nhibernate/src/NHibernate/Linq/ReWriters/MergeAggregatingResultsRewriter.cs
trunk/nhibernate/src/NHibernate/Linq/ReWriters/RemoveUnnecessaryBodyOperators.cs
trunk/nhibernate/src/NHibernate/Linq/ResultOperators/ClientSideTransformOperator.cs
trunk/nhibernate/src/NHibernate/Linq/ResultTransformer.cs
trunk/nhibernate/src/NHibernate/Linq/Visitors/HqlGeneratorExpressionTreeVisitor.cs
trunk/nhibernate/src/NHibernate/Linq/Visitors/NhExpressionTreeVisitor.cs
trunk/nhibernate/src/NHibernate/Linq/Visitors/Nominator.cs
trunk/nhibernate/src/NHibernate/Linq/Visitors/QueryModelVisitor.cs
trunk/nhibernate/src/NHibernate/NHibernate.csproj
trunk/nhibernate/src/NHibernate.ByteCode.LinFu/NHibernate.ByteCode.LinFu.csproj
trunk/nhibernate/src/NHibernate.DomainModel/NHibernate.DomainModel.csproj
trunk/nhibernate/src/NHibernate.Test/App.config
trunk/nhibernate/src/NHibernate.Test/Linq/Entities/Northwind.cs
trunk/nhibernate/src/NHibernate.Test/Linq/LinqQuerySamples.cs
trunk/nhibernate/src/NHibernate.Test/Linq/ParameterisedQueries.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate/Linq/Visitors/SelectClauseVisitor.cs
trunk/nhibernate/src/NHibernate.Test/Linq/CollectionAssert.cs
trunk/nhibernate/src/NHibernate.Test/Linq/Entities/UserDto.cs
trunk/nhibernate/src/NHibernate.Test/Linq/RegresstionTests.cs
trunk/nhibernate/src/NHibernate.Test/Linq/SelectionTests.cs
trunk/nhibernate/src/NHibernate.Test/Linq/WhereSubqueryTests.cs
trunk/nhibernate/src/NHibernate.Test/Linq/WhereTests.cs
Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/PolymorphicQuerySourceDetector.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/PolymorphicQuerySourceDetector.cs 2009-12-05 22:14:08 UTC (rev 4894)
+++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/PolymorphicQuerySourceDetector.cs 2009-12-16 21:36:34 UTC (rev 4895)
@@ -27,20 +27,17 @@
var className = GetClassName(querySource);
var classType = _sessionFactoryHelper.GetImportedClass(className);
- if (classType != null)
- {
- AddImplementorsToMap(querySource, classType);
- }
+ AddImplementorsToMap(querySource, classType == null ? className : classType.FullName);
}
return _map;
}
- private void AddImplementorsToMap(IASTNode querySource, System.Type classType)
+ private void AddImplementorsToMap(IASTNode querySource, string className)
{
- var implementors = _sfi.GetImplementors(classType.FullName);
+ var implementors = _sfi.GetImplementors(className);
- if (implementors.Length == 1 && implementors[0] == classType.FullName)
+ if (implementors.Length == 1 && implementors[0] == className)
{
// No need to change things
return;
Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/HqlTreeBuilder.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Hql/Ast/HqlTreeBuilder.cs 2009-12-05 22:14:08 UTC (rev 4894)
+++ trunk/nhibernate/src/NHibernate/Hql/Ast/HqlTreeBuilder.cs 2009-12-16 21:36:34 UTC (rev 4895)
@@ -341,11 +341,6 @@
return new HqlConcat(_factory, args);
}
- public HqlExpressionList ExpressionList()
- {
- return new HqlExpressionList(_factory);
- }
-
public HqlMethodCall MethodCall(string methodName, IEnumerable<HqlExpression> parameters)
{
return new HqlMethodCall(_factory, methodName, parameters);
@@ -370,6 +365,30 @@
{
return new HqlIsNotNull(_factory, lhs);
}
+
+ public HqlTreeNode ExpressionList(IEnumerable<HqlExpression> expressions)
+ {
+ return new HqlExpressionList(_factory, expressions);
+ }
+
+ public HqlStar Star()
+ {
+ return new HqlStar(_factory);
+ }
+
+ public HqlTrue True()
+ {
+ return new HqlTrue(_factory);
+ }
+
+ public HqlFalse False()
+ {
+ return new HqlFalse(_factory);
+ }
+
+ public HqlIn In(HqlExpression itemExpression, HqlTreeNode source)
+ {
+ return new HqlIn(_factory, itemExpression, source);
+ }
}
-
}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/HqlTreeNode.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Hql/Ast/HqlTreeNode.cs 2009-12-05 22:14:08 UTC (rev 4894)
+++ trunk/nhibernate/src/NHibernate/Hql/Ast/HqlTreeNode.cs 2009-12-16 21:36:34 UTC (rev 4895)
@@ -8,11 +8,13 @@
{
public class HqlTreeNode
{
+ public IASTFactory Factory { get; private set; }
private readonly IASTNode _node;
private readonly List<HqlTreeNode> _children;
protected HqlTreeNode(int type, string text, IASTFactory factory, IEnumerable<HqlTreeNode> children)
{
+ Factory = factory;
_node = factory.CreateNode(type, text);
_children = new List<HqlTreeNode>();
@@ -107,18 +109,27 @@
_node.AddChild(child.AstNode);
}
}
+ }
- public HqlExpression AsExpression()
+ public static class HqlTreeNodeExtensions
+ {
+ public static HqlExpression AsExpression(this HqlTreeNode node)
{
// TODO - nice error handling if cast fails
- return (HqlExpression) this;
+ return (HqlExpression)node;
}
- public virtual HqlBooleanExpression AsBooleanExpression()
+ public static HqlBooleanExpression AsBooleanExpression(this HqlTreeNode node)
{
+ if (node is HqlDot)
+ {
+ return new HqlBooleanDot(node.Factory, (HqlDot) node);
+ }
+
// TODO - nice error handling if cast fails
- return (HqlBooleanExpression)this;
+ return (HqlBooleanExpression)node;
}
+
}
public abstract class HqlStatement : HqlTreeNode
@@ -329,20 +340,10 @@
public class HqlDot : HqlExpression
{
- private readonly IASTFactory _factory;
-
public HqlDot(IASTFactory factory, HqlExpression lhs, HqlExpression rhs)
: base(HqlSqlWalker.DOT, ".", factory, lhs, rhs)
{
- _factory = factory;
}
-
- public override HqlBooleanExpression AsBooleanExpression()
- {
- // If we are of boolean type, then we can acts as boolean expression
- // TODO - implement type check
- return new HqlBooleanDot(_factory, this);
- }
}
public class HqlBooleanDot : HqlBooleanExpression
@@ -408,6 +409,23 @@
}
}
+ public class HqlFalse : HqlConstant
+ {
+ public HqlFalse(IASTFactory factory)
+ : base(factory, HqlSqlWalker.FALSE, "false")
+ {
+ }
+ }
+
+ public class HqlTrue : HqlConstant
+ {
+ public HqlTrue(IASTFactory factory)
+ : base(factory, HqlSqlWalker.TRUE, "true")
+ {
+ }
+ }
+
+
public class HqlNull : HqlConstant
{
public HqlNull(IASTFactory factory)
@@ -430,15 +448,23 @@
Descending
}
- public class HqlDirectionAscending : HqlStatement
+ public class HqlDirectionStatement : HqlStatement
{
+ public HqlDirectionStatement(int type, string text, IASTFactory factory)
+ : base(type, text, factory)
+ {
+ }
+ }
+
+ public class HqlDirectionAscending : HqlDirectionStatement
+ {
public HqlDirectionAscending(IASTFactory factory)
: base(HqlSqlWalker.ASCENDING, "asc", factory)
{
}
}
- public class HqlDirectionDescending : HqlStatement
+ public class HqlDirectionDescending : HqlDirectionStatement
{
public HqlDirectionDescending(IASTFactory factory)
: base(HqlSqlWalker.DESCENDING, "desc", factory)
@@ -733,4 +759,28 @@
{
}
}
+
+ public class HqlStar : HqlExpression
+ {
+ public HqlStar(IASTFactory factory) : base(HqlSqlWalker.ROW_STAR, "*", factory)
+ {
+ }
+ }
+
+ public class HqlIn : HqlBooleanExpression
+ {
+ public HqlIn(IASTFactory factory, HqlExpression itemExpression, HqlTreeNode source)
+ : base(HqlSqlWalker.IN, "in", factory, itemExpression)
+ {
+ AddChild(new HqlInList(factory, source));
+ }
+ }
+
+ public class HqlInList : HqlTreeNode
+ {
+ public HqlInList(IASTFactory factory, HqlTreeNode source)
+ : base(HqlSqlWalker.IN_LIST, "inlist", factory, source)
+ {
+ }
+ }
}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Impl/AbstractQueryImpl.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Impl/AbstractQueryImpl.cs 2009-12-05 22:14:08 UTC (rev 4894)
+++ trunk/nhibernate/src/NHibernate/Impl/AbstractQueryImpl.cs 2009-12-16 21:36:34 UTC (rev 4895)
@@ -27,7 +27,7 @@
private readonly ArrayList values = new ArrayList(4);
private readonly List<IType> types = new List<IType>(4);
private readonly Dictionary<string, TypedValue> namedParameters = new Dictionary<string, TypedValue>(4);
- private readonly Dictionary<string, TypedValue> namedParameterLists = new Dictionary<string, TypedValue>(4);
+ protected readonly Dictionary<string, TypedValue> namedParameterLists = new Dictionary<string, TypedValue>(4);
private bool cacheable;
private string cacheRegion;
private bool readOnly;
Modified: trunk/nhibernate/src/NHibernate/Impl/ExpressionQueryImpl.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Impl/ExpressionQueryImpl.cs 2009-12-05 22:14:08 UTC (rev 4894)
+++ trunk/nhibernate/src/NHibernate/Impl/ExpressionQueryImpl.cs 2009-12-16 21:36:34 UTC (rev 4895)
@@ -1,8 +1,17 @@
-using System;
+using System;
using System.Collections;
using System.Collections.Generic;
+using System.Linq;
+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
{
@@ -12,12 +21,12 @@
public IQueryExpression QueryExpression { get; private set; }
- public ExpressionQueryImpl(IQueryExpression queryExpression, ISessionImplementor session, ParameterMetadata parameterMetadata)
+ public ExpressionQueryImpl(IQueryExpression queryExpression, ISessionImplementor session, ParameterMetadata parameterMetadata)
: base(queryExpression.Key, FlushMode.Unspecified, session, parameterMetadata)
{
QueryExpression = queryExpression;
}
-
+
public override IQuery SetLockMode(string alias, LockMode lockMode)
{
_lockModes[alias] = lockMode;
@@ -51,7 +60,7 @@
Before();
try
{
- return Session.List(QueryExpression, GetQueryParameters(namedParams));
+ return Session.List(ExpandParameters(namedParams), GetQueryParameters(namedParams));
}
finally
{
@@ -59,6 +68,65 @@
}
}
+ /// <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)
+ {
+ string name = me.Key;
+ var vals = (ICollection) me.Value.Value;
+ var type = me.Value.Type;
+
+ if (vals.Count == 1)
+ {
+ // No expansion needed here
+ var iter = vals.GetEnumerator();
+ iter.MoveNext();
+ namedParamsCopy[name] = new TypedValue(type, iter.Current, Session.EntityMode);
+ continue;
+ }
+
+ var aliases = new List<string>();
+ var i = 0;
+ var 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);
+ aliases.Add(alias);
+ }
+
+ map.Add(name, aliases);
+
+ }
+
+ var 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;
+ });
+
+ return new ExpandedQueryExpression(QueryExpression, newTree, key.ToString());
+ }
+
public override void List(IList results)
{
throw new NotImplementedException();
@@ -69,4 +137,141 @@
throw new NotImplementedException();
}
}
+
+ 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 IASTNode Translate(ISessionFactory sessionFactory)
+ {
+ return _tree;
+ }
+
+ public string Key { get; private set; }
+
+ public System.Type Type { get; private set; }
+
+ public IList<NamedParameterDescriptor> ParameterDescriptors { get; private set; }
+ }
+
+ internal class ParameterExpander
+ {
+ private readonly IASTNode _tree;
+ private readonly Dictionary<string, List<string>> _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);
+
+ return expander.Expand();
+ }
+
+ private IASTNode Expand()
+ {
+ var 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 (var alias in aliases)
+ {
+ var astAlias = param.DupNode();
+ var astAliasName = paramName.DupNode();
+ astAliasName.Text = alias;
+ astAlias.AddChild(astAliasName);
+
+ astAliases.Add(astAlias);
+ }
+
+ nodeMapping.Add(param, astAliases);
+ }
+
+ return DuplicateTree(_tree, nodeMapping);
+ }
+
+ private static IASTNode DuplicateTree(IASTNode ast, IDictionary<IASTNode, IEnumerable<IASTNode>> nodeMapping)
+ {
+ var thisNode = ast.DupNode();
+
+ foreach (var 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));
+ }
+ }
+
+ return thisNode;
+ }
+ }
+
+ internal class ParameterDetector : IVisitationStrategy
+ {
+ private readonly IASTNode _tree;
+ private readonly HashSet<string> _parameterNames;
+ private readonly List<IASTNode> _nodes;
+
+ 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);
+
+ return detector.LocateParameters();
+ }
+
+ private IList<IASTNode> LocateParameters()
+ {
+ var nodeTraverser = new NodeTraverser(this);
+ nodeTraverser.TraverseDepthFirst(_tree);
+
+ return _nodes;
+ }
+
+ public void Visit(IASTNode node)
+ {
+ if ((node.Type == HqlSqlWalker.PARAM) || (node.Type == HqlSqlWalker.COLON))
+ {
+ var name = node.GetChild(0).Text;
+
+ if (_parameterNames.Contains(name))
+ {
+ _nodes.Add(node);
+ }
+ }
+ }
+
+ }
}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Linq/ExpressionToHqlTranslationResults.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Linq/ExpressionToHqlTranslationResults.cs 2009-12-05 22:14:08 UTC (rev 4894)
+++ trunk/nhibernate/src/NHibernate/Linq/ExpressionToHqlTranslationResults.cs 2009-12-16 21:36:34 UTC (rev 4895)
@@ -9,17 +9,24 @@
{
public class ExpressionToHqlTranslationResults
{
- public HqlQuery Statement { get; private set; }
+ public HqlTreeNode Statement { get; private set; }
public ResultTransformer ResultTransformer { get; private set; }
- public List<Action<IQuery, IDictionary<string, Pair<object, IType>>>> AdditionalCriteria { get; private set; }
+ public Delegate PostExecuteTransformer { get; private set; }
+ public List<Action<IQuery, IDictionary<string, Tuple<object, IType>>>> AdditionalCriteria { get; private set; }
- public ExpressionToHqlTranslationResults(HqlQuery statement, IList<LambdaExpression> itemTransformers, IList<LambdaExpression> listTransformers, List<Action<IQuery, IDictionary<string, Pair<object, IType>>>> additionalCriteria)
+ public ExpressionToHqlTranslationResults(HqlTreeNode statement,
+ IList<LambdaExpression> itemTransformers,
+ IList<LambdaExpression> listTransformers,
+ IList<LambdaExpression> postExecuteTransformers,
+ List<Action<IQuery, IDictionary<string, Tuple<object, IType>>>> additionalCriteria)
{
Statement = statement;
- var itemTransformer = MergeLambdas(itemTransformers);
- var listTransformer = MergeLambdas(listTransformers);
+ PostExecuteTransformer = MergeLambdasAndCompile(postExecuteTransformers);
+ var itemTransformer = MergeLambdasAndCompile(itemTransformers);
+ var listTransformer = MergeLambdasAndCompile(listTransformers);
+
if (itemTransformer != null || listTransformer != null)
{
ResultTransformer = new ResultTransformer(itemTransformer, listTransformer);
@@ -28,7 +35,7 @@
AdditionalCriteria = additionalCriteria;
}
- private static LambdaExpression MergeLambdas(IList<LambdaExpression> transformations)
+ private static Delegate MergeLambdasAndCompile(IList<LambdaExpression> transformations)
{
if (transformations == null || transformations.Count == 0)
{
@@ -44,7 +51,7 @@
listTransformLambda = Expression.Lambda(invoked, listTransformLambda.Parameters.ToArray());
}
- return listTransformLambda;
+ return listTransformLambda.Compile();
}
}
}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Linq/Expressions/NhExpressionType.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Linq/Expressions/NhExpressionType.cs 2009-12-05 22:14:08 UTC (rev 4894)
+++ trunk/nhibernate/src/NHibernate/Linq/Expressions/NhExpressionType.cs 2009-12-16 21:36:34 UTC (rev 4895)
@@ -8,6 +8,7 @@
Sum,
Count,
Distinct,
- New
+ New,
+ Star
}
}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Linq/Expressions/NhNewExpression.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Linq/Expressions/NhNewExpression.cs 2009-12-05 22:14:08 UTC (rev 4894)
+++ trunk/nhibernate/src/NHibernate/Linq/Expressions/NhNewExpression.cs 2009-12-16 21:36:34 UTC (rev 4895)
@@ -1,4 +1,5 @@
-using System.Collections.Generic;
+using System;
+using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq.Expressions;
@@ -26,4 +27,17 @@
get { return _members; }
}
}
+
+ public class NhStarExpression : Expression
+ {
+ public NhStarExpression(Expression expression) : base((ExpressionType) NhExpressionType.Star, expression.Type)
+ {
+ Expression = expression;
+ }
+
+ public Expression Expression
+ {
+ get; private set;
+ }
+ }
}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Linq/Functions/BaseHqlGeneratorForType.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Linq/Functions/BaseHqlGeneratorForType.cs 2009-12-05 22:14:08 UTC (rev 4894)
+++ trunk/nhibernate/src/NHibernate/Linq/Functions/BaseHqlGeneratorForType.cs 2009-12-16 21:36:34 UTC (rev 4895)
@@ -1,4 +1,6 @@
-using System.Collections.Generic;
+using System;
+using System.Collections.Generic;
+using System.Reflection;
using NHibernate.Linq.Visitors;
namespace NHibernate.Linq.Functions
@@ -26,5 +28,15 @@
}
}
}
+
+ public virtual bool SupportsMethod(MethodInfo method)
+ {
+ return false;
+ }
+
+ public virtual IHqlGeneratorForMethod GetMethodGenerator(MethodInfo method)
+ {
+ throw new NotSupportedException();
+ }
}
}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Linq/Functions/FunctionRegistry.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Linq/Functions/FunctionRegistry.cs 2009-12-05 22:14:08 UTC (rev 4894)
+++ trunk/nhibernate/src/NHibernate/Linq/Functions/FunctionRegistry.cs 2009-12-16 21:36:34 UTC (rev 4895)
@@ -36,12 +36,14 @@
registry.Register(new QueryableGenerator());
registry.Register(new StringGenerator());
registry.Register(new DateTimeGenerator());
+ registry.Register(new ICollectionGenerator());
return registry;
}
private readonly Dictionary<MethodInfo, IHqlGeneratorForMethod> _registeredMethods = new Dictionary<MethodInfo, IHqlGeneratorForMethod>();
private readonly Dictionary<MemberInfo, IHqlGeneratorForProperty> _registeredProperties = new Dictionary<MemberInfo, IHqlGeneratorForProperty>();
+ private readonly List<IHqlGeneratorForType> _typeGenerators = new List<IHqlGeneratorForType>();
public IHqlGeneratorForMethod GetMethodGenerator(MethodInfo method)
{
@@ -58,14 +60,23 @@
}
// No method generator registered. Look to see if it's a standard LinqExtensionMethod
- var attr = (LinqExtensionMethodAttribute) method.GetCustomAttributes(typeof (LinqExtensionMethodAttribute), false)[0];
- if (attr != null)
+ var attr = method.GetCustomAttributes(typeof (LinqExtensionMethodAttribute), false);
+ if (attr.Length == 1)
{
// It is
// TODO - cache this? Is it worth it?
- return new HqlGeneratorForExtensionMethod(attr, method);
+ return new HqlGeneratorForExtensionMethod((LinqExtensionMethodAttribute) attr[0], method);
}
+ // Not that either. Let's query each type generator to see if it can handle it
+ foreach (var typeGenerator in _typeGenerators)
+ {
+ if (typeGenerator.SupportsMethod(method))
+ {
+ return typeGenerator.GetMethodGenerator(method);
+ }
+ }
+
throw new NotSupportedException(method.ToString());
}
@@ -94,6 +105,7 @@
private void Register(IHqlGeneratorForType typeMethodGenerator)
{
+ _typeGenerators.Add(typeMethodGenerator);
typeMethodGenerator.Register(this);
}
}
Modified: trunk/nhibernate/src/NHibernate/Linq/Functions/IHqlGeneratorForType.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Linq/Functions/IHqlGeneratorForType.cs 2009-12-05 22:14:08 UTC (rev 4894)
+++ trunk/nhibernate/src/NHibernate/Linq/Functions/IHqlGeneratorForType.cs 2009-12-16 21:36:34 UTC (rev 4895)
@@ -1,7 +1,11 @@
-namespace NHibernate.Linq.Functions
+using System.Reflection;
+
+namespace NHibernate.Linq.Functions
{
public interface IHqlGeneratorForType
{
void Register(FunctionRegistry functionRegistry);
+ bool SupportsMethod(MethodInfo method);
+ IHqlGeneratorForMethod GetMethodGenerator(MethodInfo method);
}
}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Linq/Functions/QueryableGenerator.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Linq/Functions/QueryableGenerator.cs 2009-12-05 22:14:08 UTC (rev 4894)
+++ trunk/nhibernate/src/NHibernate/Linq/Functions/QueryableGenerator.cs 2009-12-16 21:36:34 UTC (rev 4895)
@@ -1,4 +1,6 @@
-using System.Collections.ObjectModel;
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
@@ -126,4 +128,74 @@
}
}
}
+
+ public class ICollectionGenerator : BaseHqlGeneratorForType
+ {
+ public ICollectionGenerator()
+ {
+ // TODO - could use reflection
+ MethodRegistry.Add(new ContainsGenerator());
+ }
+
+ public override bool SupportsMethod(MethodInfo method)
+ {
+ var declaringType = method.DeclaringType;
+
+ if (declaringType.IsGenericType)
+ {
+ if (declaringType.GetGenericTypeDefinition() == typeof(ICollection<>) ||
+ declaringType.GetGenericTypeDefinition() == typeof(IEnumerable<>))
+ {
+ if (method.Name == "Contains")
+ {
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
+ public override IHqlGeneratorForMethod GetMethodGenerator(MethodInfo method)
+ {
+ // TODO - ick
+ if (method.Name == "Contains")
+ {
+ return new ContainsGenerator();
+ }
+
+ throw new NotSupportedException(method.Name);
+ }
+
+ class ContainsGenerator : BaseHqlGeneratorForMethod
+ {
+ public ContainsGenerator()
+ {
+ SupportedMethods = new MethodInfo[0];
+ }
+
+ public override HqlTreeNode BuildHql(MethodInfo method, Expression targetObject, ReadOnlyCollection<Expression...
[truncated message content] |
|
From: <ste...@us...> - 2009-12-16 21:52:16
|
Revision: 4896
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4896&view=rev
Author: steverstrong
Date: 2009-12-16 21:52:08 +0000 (Wed, 16 Dec 2009)
Log Message:
-----------
Two files that should have been deleted on the last commit.
Added Paths:
-----------
trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/output/
Removed Paths:
-------------
trunk/nhibernate/src/NHibernate/Linq/CommandData.cs
trunk/nhibernate/src/NHibernate/Linq/Visitors/ProjectionEvaluator.cs
Property changes on: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/output
___________________________________________________________________
Added: bugtraq:url
+ http://jira.nhibernate.org/browse/%BUGID%
Added: bugtraq:logregex
+ NH-\d+
Deleted: trunk/nhibernate/src/NHibernate/Linq/CommandData.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Linq/CommandData.cs 2009-12-16 21:36:34 UTC (rev 4895)
+++ trunk/nhibernate/src/NHibernate/Linq/CommandData.cs 2009-12-16 21:52:08 UTC (rev 4896)
@@ -1,64 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Linq.Expressions;
-using NHibernate.Hql.Ast;
-
-namespace NHibernate.Linq
-{
- public class CommandData
- {
- private readonly List<LambdaExpression> _itemTransformers;
- private readonly List<LambdaExpression> _listTransformers;
- private readonly List<Action<IQuery>> _additionalCriteria;
-
- public CommandData(HqlQuery statement, List<LambdaExpression> itemTransformers, List<LambdaExpression> listTransformers, List<Action<IQuery>> additionalCriteria)
- {
- _itemTransformers = itemTransformers;
- _listTransformers = listTransformers;
-
- Statement = statement;
- _additionalCriteria = additionalCriteria;
- }
-
- public HqlQuery Statement { get; private set; }
-
- public void AddAdditionalCriteria(IQuery query)
- {
- foreach (var criteria in _additionalCriteria)
- {
- criteria(query);
- }
- }
-
- public void SetResultTransformer(IQuery query)
- {
- var itemTransformer = MergeLambdas(_itemTransformers);
- var listTransformer = MergeLambdas(_listTransformers);
-
- if (itemTransformer != null || listTransformer != null)
- {
- query.SetResultTransformer(new ResultTransformer(itemTransformer, listTransformer));
- }
- }
-
- private static LambdaExpression MergeLambdas(IList<LambdaExpression> transformations)
- {
- if (transformations == null || transformations.Count == 0)
- {
- return null;
- }
-
- var listTransformLambda = transformations[0];
-
- for (int i = 1; i < transformations.Count; i++)
- {
- var invoked = Expression.Invoke(transformations[i], listTransformLambda.Body);
-
- listTransformLambda = Expression.Lambda(invoked, listTransformLambda.Parameters.ToArray());
- }
-
- return listTransformLambda;
- }
- }
-}
\ No newline at end of file
Deleted: trunk/nhibernate/src/NHibernate/Linq/Visitors/ProjectionEvaluator.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Linq/Visitors/ProjectionEvaluator.cs 2009-12-16 21:36:34 UTC (rev 4895)
+++ trunk/nhibernate/src/NHibernate/Linq/Visitors/ProjectionEvaluator.cs 2009-12-16 21:52:08 UTC (rev 4896)
@@ -1,71 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq.Expressions;
-using NHibernate.Engine.Query;
-using NHibernate.Hql.Ast;
-using Remotion.Data.Linq.Parsing;
-
-namespace NHibernate.Linq.Visitors
-{
- public class ProjectionEvaluator : ExpressionTreeVisitor
- {
- private HashSet<Expression> _hqlNodes;
- private readonly ParameterExpression _inputParameter;
- private readonly Func<Expression, bool> _predicate;
- private readonly IDictionary<ConstantExpression, NamedParameter> _parameters;
- private readonly IList<NamedParameterDescriptor> _requiredHqlParameters;
- private int _iColumn;
- private readonly List<HqlExpression> _hqlTreeNodes = new List<HqlExpression>();
-
- public ProjectionEvaluator(System.Type inputType, Func<Expression, bool> predicate, IDictionary<ConstantExpression, NamedParameter> parameters, IList<NamedParameterDescriptor> requiredHqlParameters)
- {
- _inputParameter = Expression.Parameter(inputType, "input");
- _predicate = predicate;
- _parameters = parameters;
- _requiredHqlParameters = requiredHqlParameters;
- }
-
- public LambdaExpression ProjectionExpression { get; private set; }
-
- public IEnumerable<HqlExpression> GetHqlNodes()
- {
- return _hqlTreeNodes;
- }
-
- public void Visit(Expression expression)
- {
- // First, find the sub trees that can be expressed purely in HQL
- _hqlNodes = new Nominator(_predicate).Nominate(expression);
-
- // Now visit the tree
- Expression projection = VisitExpression(expression);
-
- if ((projection != expression) && !_hqlNodes.Contains(expression))
- {
- ProjectionExpression = Expression.Lambda(projection, _inputParameter);
- }
- }
-
- protected override Expression VisitExpression(Expression expression)
- {
- if (expression == null)
- {
- return null;
- }
-
- if (_hqlNodes.Contains(expression))
- {
- // Pure HQL evaluation - TODO - cache the Visitor?
- var hqlVisitor = new HqlGeneratorExpressionTreeVisitor(_parameters, _requiredHqlParameters);
-
- _hqlTreeNodes.Add(hqlVisitor.Visit(expression).AsExpression());
-
- return Expression.Convert(Expression.ArrayIndex(_inputParameter, Expression.Constant(_iColumn++)),
- expression.Type);
- }
-
- // Can't handle this node with HQL. Just recurse down, and emit the expression
- return base.VisitExpression(expression);
- }
- }
-}
\ 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: <ric...@us...> - 2010-01-04 15:21:26
|
Revision: 4897
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4897&view=rev
Author: ricbrown
Date: 2010-01-04 15:20:56 +0000 (Mon, 04 Jan 2010)
Log Message:
-----------
Renamed QueryOver UniqueResult() to Single().
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs
trunk/nhibernate/src/NHibernate/IQueryOver.cs
trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs
Modified: trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs 2009-12-16 21:52:08 UTC (rev 4896)
+++ trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs 2010-01-04 15:20:56 UTC (rev 4897)
@@ -56,12 +56,12 @@
return criteria.List<U>();
}
- private TRoot UniqueResult()
+ private TRoot Single()
{
return criteria.UniqueResult<TRoot>();
}
- private U UniqueResult<U>()
+ private U Single<U>()
{
return criteria.UniqueResult<U>();
}
@@ -125,11 +125,11 @@
IList<U> IQueryOver<TRoot>.List<U>()
{ return List<U>(); }
- TRoot IQueryOver<TRoot>.UniqueResult()
- { return UniqueResult(); }
+ TRoot IQueryOver<TRoot>.Single()
+ { return Single(); }
- U IQueryOver<TRoot>.UniqueResult<U>()
- { return UniqueResult<U>(); }
+ U IQueryOver<TRoot>.Single<U>()
+ { return Single<U>(); }
IEnumerable<TRoot> IQueryOver<TRoot>.Future()
{ return Future(); }
Modified: trunk/nhibernate/src/NHibernate/IQueryOver.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/IQueryOver.cs 2009-12-16 21:52:08 UTC (rev 4896)
+++ trunk/nhibernate/src/NHibernate/IQueryOver.cs 2010-01-04 15:20:56 UTC (rev 4897)
@@ -49,12 +49,12 @@
/// <exception cref="HibernateException">
/// If there is more than one matching result
/// </exception>
- TRoot UniqueResult();
+ TRoot Single();
/// <summary>
- /// Override type of <see cref="UniqueResult()" />.
+ /// Override type of <see cref="Single()" />.
/// </summary>
- U UniqueResult<U>();
+ U Single<U>();
/// <summary>
/// Get a enumerable that when enumerated will execute
Modified: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs 2009-12-16 21:52:08 UTC (rev 4896)
+++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs 2010-01-04 15:20:56 UTC (rev 4897)
@@ -159,7 +159,7 @@
{
Person actual =
s.QueryOver<Person>()
- .UniqueResult();
+ .Single();
Assert.That(actual.Name, Is.EqualTo("test person 1"));
}
@@ -169,7 +169,7 @@
string actual =
s.QueryOver<Person>()
.Select(p => p.Name)
- .UniqueResult<string>();
+ .Single<string>();
Assert.That(actual, Is.EqualTo("test person 1"));
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ric...@us...> - 2010-01-04 15:35:25
|
Revision: 4898
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4898&view=rev
Author: ricbrown
Date: 2010-01-04 15:35:10 +0000 (Mon, 04 Jan 2010)
Log Message:
-----------
Renamed QueryOver.Single() to SingleOrDefault() to closer mimic semantics of Linq extension methods of the same name.
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs
trunk/nhibernate/src/NHibernate/IQueryOver.cs
trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs
Modified: trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs 2010-01-04 15:20:56 UTC (rev 4897)
+++ trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs 2010-01-04 15:35:10 UTC (rev 4898)
@@ -56,12 +56,12 @@
return criteria.List<U>();
}
- private TRoot Single()
+ private TRoot SingleOrDefault()
{
return criteria.UniqueResult<TRoot>();
}
- private U Single<U>()
+ private U SingleOrDefault<U>()
{
return criteria.UniqueResult<U>();
}
@@ -125,11 +125,11 @@
IList<U> IQueryOver<TRoot>.List<U>()
{ return List<U>(); }
- TRoot IQueryOver<TRoot>.Single()
- { return Single(); }
+ TRoot IQueryOver<TRoot>.SingleOrDefault()
+ { return SingleOrDefault(); }
- U IQueryOver<TRoot>.Single<U>()
- { return Single<U>(); }
+ U IQueryOver<TRoot>.SingleOrDefault<U>()
+ { return SingleOrDefault<U>(); }
IEnumerable<TRoot> IQueryOver<TRoot>.Future()
{ return Future(); }
Modified: trunk/nhibernate/src/NHibernate/IQueryOver.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/IQueryOver.cs 2010-01-04 15:20:56 UTC (rev 4897)
+++ trunk/nhibernate/src/NHibernate/IQueryOver.cs 2010-01-04 15:35:10 UTC (rev 4898)
@@ -49,12 +49,12 @@
/// <exception cref="HibernateException">
/// If there is more than one matching result
/// </exception>
- TRoot Single();
+ TRoot SingleOrDefault();
/// <summary>
- /// Override type of <see cref="Single()" />.
+ /// Override type of <see cref="SingleOrDefault()" />.
/// </summary>
- U Single<U>();
+ U SingleOrDefault<U>();
/// <summary>
/// Get a enumerable that when enumerated will execute
Modified: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs 2010-01-04 15:20:56 UTC (rev 4897)
+++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs 2010-01-04 15:35:10 UTC (rev 4898)
@@ -159,7 +159,7 @@
{
Person actual =
s.QueryOver<Person>()
- .Single();
+ .SingleOrDefault();
Assert.That(actual.Name, Is.EqualTo("test person 1"));
}
@@ -169,7 +169,7 @@
string actual =
s.QueryOver<Person>()
.Select(p => p.Name)
- .Single<string>();
+ .SingleOrDefault<string>();
Assert.That(actual, Is.EqualTo("test person 1"));
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2010-01-05 22:09:34
|
Revision: 4899
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4899&view=rev
Author: fabiomaulo
Date: 2010-01-05 22:09:23 +0000 (Tue, 05 Jan 2010)
Log Message:
-----------
Removed the usage of System.Xml from binders.
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Cfg/Configuration.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmAny.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmArray.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmBag.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmCollectionId.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmComponent.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmDynamicComponent.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmElement.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmIdbag.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmIndex.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmIndexManyToAny.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmIndexManyToMany.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmKey.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmKeyManyToOne.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmKeyProperty.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmList.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmManyToAny.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmManyToMany.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmManyToOne.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmMap.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmMapKey.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmMapKeyManyToMany.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmOneToOne.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmPrimitiveArray.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmProperty.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmSet.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/IEntityPropertyMapping.cs
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/Binder.cs
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassIdBinder.cs
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/CollectionBinder.cs
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/FiltersBinder.cs
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/JoinedSubclassBinder.cs
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/MappingRootBinder.cs
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/PropertiesBinder.cs
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/RootClassBinder.cs
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/SubclassBinder.cs
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/UnionSubclassBinder.cs
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ValuePropertyBinder.cs
trunk/nhibernate/src/NHibernate/NHibernate.csproj
trunk/nhibernate/src/NHibernate.Test/FilterTest/defs.hbm.xml
Added Paths:
-----------
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmCompositeElement.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmCompositeIndex.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmCompositeMapKey.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmNestedCompositeElement.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmOneToMany.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/IAnyMapping.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/ICollectionPropertiesMapping.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/ICollectionSqlsMapping.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/IComponentMapping.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/IIndexedCollectionMapping.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/IRelationship.cs
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/IdGeneratorBinder.cs
Removed Paths:
-------------
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/ICollectionPropertyMapping.cs
Modified: trunk/nhibernate/src/NHibernate/Cfg/Configuration.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/Configuration.cs 2010-01-04 15:35:10 UTC (rev 4898)
+++ trunk/nhibernate/src/NHibernate/Cfg/Configuration.cs 2010-01-05 22:09:23 UTC (rev 4899)
@@ -965,11 +965,15 @@
if (FilterDefinitions.Count > 0)
{
filterNames.Clear();
- var filterables = new JoinedEnumerable(ClassMappings, CollectionMappings);
- foreach (IFilterable filterable in filterables)
+ foreach (var persistentClass in ClassMappings)
{
- filterNames.AddAll(filterable.FilterMap.Keys);
+ filterNames.AddAll(persistentClass.FilterMap.Keys);
}
+ foreach (var collectionMapping in CollectionMappings)
+ {
+ filterNames.AddAll(collectionMapping.FilterMap.Keys);
+ filterNames.AddAll(collectionMapping.ManyToManyFilterMap.Keys);
+ }
foreach (var filterName in FilterDefinitions.Keys)
{
if (!filterNames.Contains(filterName))
Modified: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmAny.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmAny.cs 2010-01-04 15:35:10 UTC (rev 4898)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmAny.cs 2010-01-05 22:09:23 UTC (rev 4899)
@@ -3,7 +3,7 @@
namespace NHibernate.Cfg.MappingSchema
{
- public partial class HbmAny : AbstractDecoratable, IEntityPropertyMapping, IColumnsMapping
+ public partial class HbmAny : AbstractDecoratable, IEntityPropertyMapping, IColumnsMapping, IAnyMapping
{
#region Implementation of IEntityPropertyMapping
@@ -17,7 +17,7 @@
get { return access; }
}
- public bool OptimisticKock
+ public bool OptimisticLock
{
get { return optimisticlock; }
}
@@ -57,5 +57,22 @@
};
}
}
+
+ #region Implementation of IAnyMapping
+
+ public string MetaType
+ {
+ get { return metatype; }
+ }
+
+ public ICollection<HbmMetaValue> MetaValues
+ {
+ get
+ {
+ return metavalue ?? new HbmMetaValue[0];
+ }
+ }
+
+ #endregion
}
}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmArray.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmArray.cs 2010-01-04 15:35:10 UTC (rev 4898)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmArray.cs 2010-01-05 22:09:23 UTC (rev 4899)
@@ -1,8 +1,8 @@
-using System;
+using System.Collections.Generic;
namespace NHibernate.Cfg.MappingSchema
{
- public partial class HbmArray : AbstractDecoratable, ICollectionPropertyMapping
+ public partial class HbmArray : AbstractDecoratable, ICollectionPropertiesMapping, IIndexedCollectionMapping
{
#region Implementation of IEntityPropertyMapping
@@ -16,7 +16,7 @@
get { return access; }
}
- public bool OptimisticKock
+ public bool OptimisticLock
{
get { return optimisticlock; }
}
@@ -41,5 +41,151 @@
#endregion
+ #region Implementation of ICollectionSqlsMapping
+
+ public HbmLoader SqlLoader
+ {
+ get { return loader; }
+ }
+
+ public HbmCustomSQL SqlInsert
+ {
+ get { return sqlinsert; }
+ }
+
+ public HbmCustomSQL SqlUpdate
+ {
+ get { return sqlupdate; }
+ }
+
+ public HbmCustomSQL SqlDelete
+ {
+ get { return sqldelete; }
+ }
+
+ public HbmCustomSQL SqlDeleteAll
+ {
+ get { return sqldeleteall; }
+ }
+
+ #endregion
+
+ #region Implementation of ICollectionPropertyMapping
+
+ public bool Inverse
+ {
+ get { return inverse; }
+ }
+
+ public bool Mutable
+ {
+ get { return mutable; }
+ }
+
+ public string OrderBy
+ {
+ get { return null; }
+ }
+
+ public string Where
+ {
+ get { return @where; }
+ }
+
+ public int? BatchSize
+ {
+ get { return batchsizeSpecified ? batchsize : (int?)null; }
+ }
+
+ public string PersisterQualifiedName
+ {
+ get { return persister; }
+ }
+
+ public string CollectionType
+ {
+ get { return collectiontype; }
+ }
+
+ public HbmCollectionFetchMode? FetchMode
+ {
+ get { return fetchSpecified ? (HbmCollectionFetchMode?) fetch : null; }
+ }
+
+ public HbmOuterJoinStrategy? OuterJoin
+ {
+ get { return outerjoinSpecified ? (HbmOuterJoinStrategy?) outerjoin : null; }
+ }
+
+ public HbmCollectionLazy? Lazy
+ {
+ get { return null; }
+ }
+
+ public string Table
+ {
+ get { return table; }
+ }
+
+ public string Schema
+ {
+ get { return schema; }
+ }
+
+ public string Catalog
+ {
+ get { return catalog; }
+ }
+
+ public string Check
+ {
+ get { return check; }
+ }
+
+ public object ElementRelationship
+ {
+ get { return Item1; }
+ }
+
+ public string Sort
+ {
+ get { return null; }
+ }
+
+ public bool? Generic
+ {
+ get { return null; }
+ }
+
+ public IEnumerable<HbmFilter> Filters
+ {
+ get { yield break; }
+ }
+
+ public HbmKey Key
+ {
+ get { return key; }
+ }
+
+ public HbmCache Cache
+ {
+ get { return cache; }
+ }
+
+ #endregion
+
+ #region Implementation of IIndexedCollection
+
+ public HbmListIndex ListIndex
+ {
+ get { return Item as HbmListIndex; }
+ }
+
+ public HbmIndex Index
+ {
+ get { return Item as HbmIndex; }
+ }
+
+ #endregion
}
}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmBag.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmBag.cs 2010-01-04 15:35:10 UTC (rev 4898)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmBag.cs 2010-01-05 22:09:23 UTC (rev 4899)
@@ -1,6 +1,9 @@
+using System;
+using System.Collections.Generic;
+
namespace NHibernate.Cfg.MappingSchema
{
- public partial class HbmBag : AbstractDecoratable, ICollectionPropertyMapping
+ public partial class HbmBag : AbstractDecoratable, ICollectionPropertiesMapping
{
#region Implementation of IEntityPropertyMapping
@@ -14,7 +17,7 @@
get { return access; }
}
- public bool OptimisticKock
+ public bool OptimisticLock
{
get { return optimisticlock; }
}
@@ -38,5 +41,138 @@
}
#endregion
+
+ #region Implementation of ICollectionSqlsMapping
+
+ public HbmLoader SqlLoader
+ {
+ get { return loader; }
+ }
+
+ public HbmCustomSQL SqlInsert
+ {
+ get { return sqlinsert; }
+ }
+
+ public HbmCustomSQL SqlUpdate
+ {
+ get { return sqlupdate; }
+ }
+
+ public HbmCustomSQL SqlDelete
+ {
+ get { return sqldelete; }
+ }
+
+ public HbmCustomSQL SqlDeleteAll
+ {
+ get { return sqldeleteall; }
+ }
+
+ #endregion
+
+ #region Implementation of ICollectionPropertiesMapping
+
+ public bool Inverse
+ {
+ get { return inverse; }
+ }
+
+ public bool Mutable
+ {
+ get { return mutable; }
+ }
+
+ public string OrderBy
+ {
+ get { return orderby; }
+ }
+
+ public string Where
+ {
+ get { return where; }
+ }
+
+ public int? BatchSize
+ {
+ get { return batchsizeSpecified ? batchsize: (int?) null; }
+ }
+
+ public string PersisterQualifiedName
+ {
+ get { return persister; }
+ }
+
+ public string CollectionType
+ {
+ get { return collectiontype; }
+ }
+
+ public HbmCollectionFetchMode? FetchMode
+ {
+ get { return fetchSpecified ? fetch: (HbmCollectionFetchMode?) null; }
+ }
+
+ public HbmOuterJoinStrategy? OuterJoin
+ {
+ get { return outerjoinSpecified ? outerjoin:(HbmOuterJoinStrategy?) null; }
+ }
+
+ public HbmCollectionLazy? Lazy
+ {
+ get { return lazySpecified ? lazy : (HbmCollectionLazy?)null; }
+ }
+
+ public string Table
+ {
+ get { return table; }
+ }
+
+ public string Schema
+ {
+ get { return schema; }
+ }
+
+ public string Catalog
+ {
+ get { return catalog; }
+ }
+
+ public string Check
+ {
+ get { return check; }
+ }
+
+ public object ElementRelationship
+ {
+ get { return Item; }
+ }
+
+ public string Sort
+ {
+ get { return null; }
+ }
+
+ public bool? Generic
+ {
+ get { return genericSpecified ? generic: (bool?) null; }
+ }
+
+ public IEnumerable<HbmFilter> Filters
+ {
+ get { return filter ?? new HbmFilter[0]; }
+ }
+
+ public HbmKey Key
+ {
+ get { return key; }
+ }
+
+ public HbmCache Cache
+ {
+ get { return cache; }
+ }
+
+ #endregion
}
}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmCollectionId.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmCollectionId.cs 2010-01-04 15:35:10 UTC (rev 4898)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmCollectionId.cs 2010-01-05 22:09:23 UTC (rev 4899)
@@ -2,7 +2,7 @@
namespace NHibernate.Cfg.MappingSchema
{
- public partial class HbmCollectionId: IColumnsMapping
+ public partial class HbmCollectionId : IColumnsMapping, ITypeMapping
{
#region Implementation of IColumnsMapping
@@ -28,5 +28,14 @@
};
}
}
+
+ #region Implementation of ITypeMapping
+
+ public HbmType Type
+ {
+ get { return !string.IsNullOrEmpty(type) ? new HbmType { name = type } : null; }
+ }
+
+ #endregion
}
}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmComponent.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmComponent.cs 2010-01-04 15:35:10 UTC (rev 4898)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmComponent.cs 2010-01-05 22:09:23 UTC (rev 4899)
@@ -4,10 +4,25 @@
namespace NHibernate.Cfg.MappingSchema
{
- public partial class HbmComponent : AbstractDecoratable, IEntityPropertyMapping, IPropertiesContainerMapping
+ public partial class HbmComponent : AbstractDecoratable, IEntityPropertyMapping, IComponentMapping
{
#region Implementation of IEntityPropertyMapping
+ public string Class
+ {
+ get { return @class; }
+ }
+
+ public HbmParent Parent
+ {
+ get { return parent; }
+ }
+
+ public string EmbeddedNode
+ {
+ get { return node; }
+ }
+
public string Name
{
get { return name; }
@@ -18,7 +33,7 @@
get { return access; }
}
- public bool OptimisticKock
+ public bool OptimisticLock
{
get { return optimisticlock; }
}
Added: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmCompositeElement.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmCompositeElement.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmCompositeElement.cs 2010-01-05 22:09:23 UTC (rev 4899)
@@ -0,0 +1,51 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace NHibernate.Cfg.MappingSchema
+{
+ public partial class HbmCompositeElement : AbstractDecoratable, IComponentMapping
+ {
+ #region Implementation of IComponentMapping
+
+ public string Class
+ {
+ get { return @class; }
+ }
+
+ public HbmParent Parent
+ {
+ get { return parent; }
+ }
+
+ public string EmbeddedNode
+ {
+ get { return node;}
+ }
+
+ public string Name
+ {
+ get { return null; }
+ }
+
+ #endregion
+
+ #region Overrides of AbstractDecoratable
+
+ protected override HbmMeta[] Metadatas
+ {
+ get { return meta ?? new HbmMeta[0]; }
+ }
+
+ #endregion
+
+ #region Implementation of IPropertiesContainerMapping
+
+ public IEnumerable<IEntityPropertyMapping> Properties
+ {
+ get { return Items != null ? Items.Cast<IEntityPropertyMapping>() : new IEntityPropertyMapping[0]; }
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmCompositeIndex.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmCompositeIndex.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmCompositeIndex.cs 2010-01-05 22:09:23 UTC (rev 4899)
@@ -0,0 +1,42 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace NHibernate.Cfg.MappingSchema
+{
+ public partial class HbmCompositeIndex: IComponentMapping
+ {
+ #region Implementation of IPropertiesContainerMapping
+
+ public IEnumerable<IEntityPropertyMapping> Properties
+ {
+ get { return Items != null ? Items.Cast<IEntityPropertyMapping>() : new IEntityPropertyMapping[0]; }
+ }
+
+ #endregion
+
+ #region Implementation of IComponentMapping
+
+ public string Class
+ {
+ get { return @class; }
+ }
+
+ public HbmParent Parent
+ {
+ get { return null; }
+ }
+
+ public string EmbeddedNode
+ {
+ get { return null; }
+ }
+
+ public string Name
+ {
+ get { return null; }
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmCompositeMapKey.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmCompositeMapKey.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmCompositeMapKey.cs 2010-01-05 22:09:23 UTC (rev 4899)
@@ -0,0 +1,42 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace NHibernate.Cfg.MappingSchema
+{
+ public partial class HbmCompositeMapKey: IComponentMapping
+ {
+ #region Implementation of IPropertiesContainerMapping
+
+ public IEnumerable<IEntityPropertyMapping> Properties
+ {
+ get { return Items != null ? Items.Cast<IEntityPropertyMapping>() : new IEntityPropertyMapping[0]; }
+ }
+
+ #endregion
+
+ #region Implementation of IComponentMapping
+
+ public string Class
+ {
+ get { return @class; }
+ }
+
+ public HbmParent Parent
+ {
+ get { return null; }
+ }
+
+ public string EmbeddedNode
+ {
+ get { return null; }
+ }
+
+ public string Name
+ {
+ get { return null; }
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmDynamicComponent.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmDynamicComponent.cs 2010-01-04 15:35:10 UTC (rev 4898)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmDynamicComponent.cs 2010-01-05 22:09:23 UTC (rev 4899)
@@ -1,3 +1,4 @@
+using System;
using System.Collections.Generic;
using System.Linq;
@@ -3,8 +4,23 @@
namespace NHibernate.Cfg.MappingSchema
{
- public partial class HbmDynamicComponent: AbstractDecoratable, IEntityPropertyMapping, IPropertiesContainerMapping
+ public partial class HbmDynamicComponent: AbstractDecoratable, IEntityPropertyMapping, IComponentMapping
{
#region Implementation of IEntityPropertyMapping
+ public string Class
+ {
+ get { return null; }
+ }
+
+ public HbmParent Parent
+ {
+ get { return null; }
+ }
+
+ public string EmbeddedNode
+ {
+ get { return node; }
+ }
+
public string Name
{
@@ -17,7 +33,7 @@
get { return access; }
}
- public bool OptimisticKock
+ public bool OptimisticLock
{
get { return optimisticlock; }
}
Modified: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmElement.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmElement.cs 2010-01-04 15:35:10 UTC (rev 4898)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmElement.cs 2010-01-05 22:09:23 UTC (rev 4899)
@@ -23,16 +23,18 @@
}
else
{
- yield return new HbmColumn
- {
- name = column,
- length = length,
- scale = scale,
- precision = precision,
- notnull = notnull,
- unique = unique,
- uniqueSpecified = true,
- };
+ yield return
+ new HbmColumn
+ {
+ name = column,
+ length = length,
+ scale = scale,
+ precision = precision,
+ notnull = notnull,
+ notnullSpecified = true,
+ unique = unique,
+ uniqueSpecified = true,
+ };
}
}
Modified: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmIdbag.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmIdbag.cs 2010-01-04 15:35:10 UTC (rev 4898)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmIdbag.cs 2010-01-05 22:09:23 UTC (rev 4899)
@@ -1,6 +1,8 @@
+using System.Collections.Generic;
+
namespace NHibernate.Cfg.MappingSchema
{
- public partial class HbmIdbag : AbstractDecoratable, ICollectionPropertyMapping
+ public partial class HbmIdbag : AbstractDecoratable, ICollectionPropertiesMapping
{
#region Implementation of IEntityPropertyMapping
@@ -14,7 +16,7 @@
get { return access; }
}
- public bool OptimisticKock
+ public bool OptimisticLock
{
get { return optimisticlock; }
}
@@ -38,5 +40,139 @@
}
#endregion
+
+ #region Implementation of ICollectionSqlsMapping
+
+ public HbmLoader SqlLoader
+ {
+ get { return loader; }
+ }
+
+ public HbmCustomSQL SqlInsert
+ {
+ get { return sqlinsert; }
+ }
+
+ public HbmCustomSQL SqlUpdate
+ {
+ get { return sqlupdate; }
+ }
+
+ public HbmCustomSQL SqlDelete
+ {
+ get { return sqldelete; }
+ }
+
+ public HbmCustomSQL SqlDeleteAll
+ {
+ get { return sqldeleteall; }
+ }
+
+ #endregion
+
+ #region Implementation of ICollectionPropertiesMapping
+
+ public bool Inverse
+ {
+ get { return inverse; }
+ }
+
+ public bool Mutable
+ {
+ get { return mutable; }
+ }
+
+ public string OrderBy
+ {
+ get { return orderby; }
+ }
+
+ public string Where
+ {
+ get { return where; }
+ }
+
+ public int? BatchSize
+ {
+ get { return batchsizeSpecified ? batchsize : (int?)null; }
+ }
+
+ public string PersisterQualifiedName
+ {
+ get { return persister; }
+ }
+
+ public string CollectionType
+ {
+ get { return collectiontype; }
+ }
+
+ public HbmCollectionFetchMode? FetchMode
+ {
+ get { return fetchSpecified ? fetch : (HbmCollectionFetchMode?)null; }
+ }
+
+ public HbmOuterJoinStrategy? OuterJoin
+ {
+ get { return outerjoinSpecified ? outerjoin : (HbmOuterJoinStrategy?)null; }
+ }
+
+ public HbmCollectionLazy? Lazy
+ {
+ get { return lazySpecified ? lazy : (HbmCollectionLazy?)null; }
+ }
+
+ public string Table
+ {
+ get { return table; }
+ }
+
+ public string Schema
+ {
+ get { return schema; }
+ }
+
+ public string Catalog
+ {
+ get { return catalog; }
+ }
+
+ public string Check
+ {
+ get { return check; }
+ }
+
+ public object ElementRelationship
+ {
+ get { return Item; }
+ }
+
+ public string Sort
+ {
+ get { return null; }
+ }
+
+ public bool? Generic
+ {
+ get { return genericSpecified ? generic : (bool?)null; }
+ }
+
+ public IEnumerable<HbmFilter> Filters
+ {
+ get { return filter ?? new HbmFilter[0]; }
+ }
+
+ public HbmKey Key
+ {
+ get { return key; }
+ }
+
+ public HbmCache Cache
+ {
+ get { return cache; }
+ }
+
+ #endregion
+
}
}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmIndex.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmIndex.cs 2010-01-04 15:35:10 UTC (rev 4898)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmIndex.cs 2010-01-05 22:09:23 UTC (rev 4899)
@@ -1,3 +1,4 @@
+using System;
using System.Collections.Generic;
namespace NHibernate.Cfg.MappingSchema
@@ -2,3 +3,3 @@
{
- public partial class HbmIndex: IColumnsMapping
+ public partial class HbmIndex: IColumnsMapping, ITypeMapping
{
@@ -28,5 +29,14 @@
};
}
}
+
+ #region Implementation of ITypeMapping
+
+ public HbmType Type
+ {
+ get { return string.IsNullOrEmpty(type) ? null : new HbmType {name = type}; }
+ }
+
+ #endregion
}
}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmIndexManyToAny.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmIndexManyToAny.cs 2010-01-04 15:35:10 UTC (rev 4898)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmIndexManyToAny.cs 2010-01-05 22:09:23 UTC (rev 4899)
@@ -1,3 +1,4 @@
+using System;
using System.Collections.Generic;
namespace NHibernate.Cfg.MappingSchema
@@ -2,3 +3,3 @@
{
- public partial class HbmIndexManyToAny: IColumnsMapping
+ public partial class HbmIndexManyToAny: IColumnsMapping, IAnyMapping
{
@@ -27,5 +28,19 @@
};
}
}
+
+ #region Implementation of IAnyMapping
+
+ public string MetaType
+ {
+ get { return metatype; }
+ }
+
+ public ICollection<HbmMetaValue> MetaValues
+ {
+ get { return new HbmMetaValue[0]; }
+ }
+
+ #endregion
}
}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmIndexManyToMany.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmIndexManyToMany.cs 2010-01-04 15:35:10 UTC (rev 4898)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmIndexManyToMany.cs 2010-01-05 22:09:23 UTC (rev 4899)
@@ -2,7 +2,7 @@
namespace NHibernate.Cfg.MappingSchema
{
- public partial class HbmIndexManyToMany: IColumnsMapping
+ public partial class HbmIndexManyToMany: IColumnsMapping, IRelationship
{
#region Implementation of IColumnsMapping
@@ -27,5 +27,24 @@
};
}
}
+
+ #region Implementation of IRelationship
+
+ public string EntityName
+ {
+ get { return entityname; }
+ }
+
+ public string Class
+ {
+ get { return @class; }
+ }
+
+ public HbmNotFoundMode NotFoundMode
+ {
+ get { return HbmNotFoundMode.Exception; }
+ }
+
+ #endregion
}
}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmKey.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmKey.cs 2010-01-04 15:35:10 UTC (rev 4898)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmKey.cs 2010-01-05 22:09:23 UTC (rev 4899)
@@ -31,5 +31,15 @@
};
}
}
+
+ public bool? IsNullable
+ {
+ get { return notnullSpecified ? !notnull : (bool?)null; }
+ }
+
+ public bool? IsUpdatable
+ {
+ get { return updateSpecified ? update : (bool?)null; }
+ }
}
}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmKeyManyToOne.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmKeyManyToOne.cs 2010-01-04 15:35:10 UTC (rev 4898)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmKeyManyToOne.cs 2010-01-05 22:09:23 UTC (rev 4899)
@@ -1,3 +1,4 @@
+using System;
using System.Collections.Generic;
namespace NHibernate.Cfg.MappingSchema
@@ -2,3 +3,3 @@
{
- public partial class HbmKeyManyToOne: IColumnsMapping
+ public partial class HbmKeyManyToOne : AbstractDecoratable, IColumnsMapping, IRelationship, IEntityPropertyMapping
{
@@ -28,5 +29,57 @@
};
}
}
+
+ #region Overrides of AbstractDecoratable
+
+ protected override HbmMeta[] Metadatas
+ {
+ get { return meta ?? new HbmMeta[0]; }
+ }
+
+ #endregion
+
+ public HbmRestrictedLaziness? Lazy
+ {
+ get { return lazySpecified ? lazy : (HbmRestrictedLaziness?)null; }
+ }
+
+ #region Implementation of IRelationship
+
+ public string EntityName
+ {
+ get { return entityname; }
+ }
+
+ public string Class
+ {
+ get { return @class; }
+ }
+
+ public HbmNotFoundMode NotFoundMode
+ {
+ get { return notfound; }
+ }
+
+ #endregion
+
+ #region Implementation of IEntityPropertyMapping
+
+ public string Name
+ {
+ get { return name; }
+ }
+
+ public string Access
+ {
+ get { return access; }
+ }
+
+ public bool OptimisticLock
+ {
+ get { return false; }
+ }
+
+ #endregion
}
}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmKeyProperty.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmKeyProperty.cs 2010-01-04 15:35:10 UTC (rev 4898)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmKeyProperty.cs 2010-01-05 22:09:23 UTC (rev 4899)
@@ -1,3 +1,4 @@
+using System;
using System.Collections.Generic;
namespace NHibernate.Cfg.MappingSchema
@@ -2,3 +3,3 @@
{
- public partial class HbmKeyProperty: IColumnsMapping, ITypeMapping
+ public partial class HbmKeyProperty : AbstractDecoratable, IColumnsMapping, ITypeMapping, IEntityPropertyMapping
{
@@ -38,5 +39,33 @@
}
#endregion
+
+ #region Overrides of AbstractDecoratable
+
+ protected override HbmMeta[] Metadatas
+ {
+ get { return meta ?? new HbmMeta[0]; }
+ }
+
+ #endregion
+
+ #region Implementation of IEntityPropertyMapping
+
+ public string Name
+ {
+ get { return name; }
+ }
+
+ public string Access
+ {
+ get { return access; }
+ }
+
+ public bool OptimisticLock
+ {
+ get { return false; }
+ }
+
+ #endregion
}
}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmList.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmList.cs 2010-01-04 15:35:10 UTC (rev 4898)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmList.cs 2010-01-05 22:09:23 UTC (rev 4899)
@@ -1,6 +1,8 @@
+using System.Collections.Generic;
+
namespace NHibernate.Cfg.MappingSchema
{
- public partial class HbmList : AbstractDecoratable, ICollectionPropertyMapping
+ public partial class HbmList : AbstractDecoratable, ICollectionPropertiesMapping, IIndexedCollectionMapping
{
#region Implementation of IEntityPropertyMapping
@@ -14,7 +16,7 @@
get { return access; }
}
- public bool OptimisticKock
+ public bool OptimisticLock
{
get { return optimisticlock; }
}
@@ -39,5 +41,151 @@
#endregion
+ #region Implementation of ICollectionSqlsMapping
+
+ public HbmLoader SqlLoader
+ {
+ get { return loader; }
+ }
+
+ public HbmC...
[truncated message content] |
|
From: <fab...@us...> - 2010-01-05 22:56:46
|
Revision: 4901
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4901&view=rev
Author: fabiomaulo
Date: 2010-01-05 22:56:37 +0000 (Tue, 05 Jan 2010)
Log Message:
-----------
Refactoring
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmExtensions.cs
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/Binder.cs
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassCompositeIdBinder.cs
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/CollectionBinder.cs
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/NamedQueryBinder.cs
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/NamedSQLQueryBinder.cs
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/RootClassBinder.cs
trunk/nhibernate/src/NHibernate/NHibernate.csproj
Removed Paths:
-------------
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/CacheModeConverter.cs
Modified: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmExtensions.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmExtensions.cs 2010-01-05 22:16:33 UTC (rev 4900)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmExtensions.cs 2010-01-05 22:56:37 UTC (rev 4901)
@@ -1,3 +1,4 @@
+using System;
using NHibernate.Engine;
namespace NHibernate.Cfg.MappingSchema
@@ -20,5 +21,56 @@
return Versioning.OptimisticLock.Version;
}
}
+
+ public static string ToNullValue(this HbmUnsavedValueType unsavedValueType)
+ {
+ switch (unsavedValueType)
+ {
+ case HbmUnsavedValueType.Undefined:
+ return "undefined";
+ case HbmUnsavedValueType.Any:
+ return "any";
+ case HbmUnsavedValueType.None:
+ return "none";
+ default:
+ throw new ArgumentOutOfRangeException("unsavedValueType");
+ }
+ }
+
+ public static string ToCacheConcurrencyStrategy(this HbmCacheUsage cacheUsage)
+ {
+ switch (cacheUsage)
+ {
+ case HbmCacheUsage.ReadOnly:
+ return "read-only";
+ case HbmCacheUsage.ReadWrite:
+ return "read-write";
+ case HbmCacheUsage.NonstrictReadWrite:
+ return "nonstrict-read-write";
+ case HbmCacheUsage.Transactional:
+ return "transactional";
+ default:
+ throw new ArgumentOutOfRangeException("cacheUsage");
+ }
+ }
+
+ public static CacheMode? ToCacheMode(this HbmCacheMode cacheMode)
+ {
+ switch (cacheMode)
+ {
+ case HbmCacheMode.Get:
+ return CacheMode.Get;
+ case HbmCacheMode.Ignore:
+ return CacheMode.Ignore;
+ case HbmCacheMode.Normal:
+ return CacheMode.Normal;
+ case HbmCacheMode.Put:
+ return CacheMode.Put;
+ case HbmCacheMode.Refresh:
+ return CacheMode.Refresh;
+ default:
+ throw new ArgumentOutOfRangeException("cacheMode");
+ }
+ }
}
}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/Binder.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/Binder.cs 2010-01-05 22:16:33 UTC (rev 4900)
+++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/Binder.cs 2010-01-05 22:56:37 UTC (rev 4901)
@@ -1,8 +1,5 @@
using System;
using System.Collections.Generic;
-using System.Reflection;
-using System.Xml.Serialization;
-
using log4net;
using NHibernate.Mapping;
using NHibernate.Type;
@@ -134,21 +131,6 @@
return ClassForNameChecked(unqualifiedName, mappings, "unknown class {0}").AssemblyQualifiedName;
}
- protected static string GetXmlEnumAttribute(Enum cascadeStyle)
- {
- MemberInfo[] memberInfo = cascadeStyle.GetType().GetMember(cascadeStyle.ToString());
-
- if (memberInfo != null && memberInfo.Length == 1)
- {
- object[] customAttributes = memberInfo[0].GetCustomAttributes(typeof(XmlEnumAttribute), false);
-
- if (customAttributes.Length == 1)
- return ((XmlEnumAttribute)customAttributes[0]).Name;
- }
-
- return null;
- }
-
public static IDictionary<string, MetaAttribute> GetMetas(IDecoratable decoratable, IDictionary<string, MetaAttribute> inheritedMeta)
{
return GetMetas(decoratable, inheritedMeta, false);
Deleted: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/CacheModeConverter.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/CacheModeConverter.cs 2010-01-05 22:16:33 UTC (rev 4900)
+++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/CacheModeConverter.cs 2010-01-05 22:56:37 UTC (rev 4901)
@@ -1,27 +0,0 @@
-using System;
-using NHibernate.Cfg.MappingSchema;
-
-namespace NHibernate.Cfg.XmlHbmBinding
-{
- internal static class CacheModeConverter
- {
- public static CacheMode? GetCacheMode(HbmCacheMode cacheMode)
- {
- switch (cacheMode)
- {
- case HbmCacheMode.Get:
- return CacheMode.Get;
- case HbmCacheMode.Ignore:
- return CacheMode.Ignore;
- case HbmCacheMode.Normal:
- return CacheMode.Normal;
- case HbmCacheMode.Put:
- return CacheMode.Put;
- case HbmCacheMode.Refresh:
- return CacheMode.Refresh;
- default:
- throw new ArgumentOutOfRangeException("cacheMode");
- }
- }
- }
-}
Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassCompositeIdBinder.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassCompositeIdBinder.cs 2010-01-05 22:16:33 UTC (rev 4900)
+++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassCompositeIdBinder.cs 2010-01-05 22:56:37 UTC (rev 4901)
@@ -37,7 +37,7 @@
}
compositeId.Table.SetIdentifierValue(compositeId);
- compositeId.NullValue = GetXmlEnumAttribute(idSchema.unsavedvalue);
+ compositeId.NullValue = idSchema.unsavedvalue.ToNullValue();
System.Type compIdClass = compositeId.ComponentClass;
if (!ReflectHelper.OverridesEquals(compIdClass))
Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/CollectionBinder.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/CollectionBinder.cs 2010-01-05 22:16:33 UTC (rev 4900)
+++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/CollectionBinder.cs 2010-01-05 22:56:37 UTC (rev 4901)
@@ -823,7 +823,7 @@
{
if (cacheSchema != null)
{
- collection.CacheConcurrencyStrategy = GetXmlEnumAttribute(cacheSchema.usage);
+ collection.CacheConcurrencyStrategy = cacheSchema.usage.ToCacheConcurrencyStrategy();
collection.CacheRegionName = cacheSchema.region;
}
}
Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/NamedQueryBinder.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/NamedQueryBinder.cs 2010-01-05 22:16:33 UTC (rev 4900)
+++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/NamedQueryBinder.cs 2010-01-05 22:56:37 UTC (rev 4901)
@@ -28,7 +28,7 @@
FlushMode flushMode = FlushModeConverter.GetFlushMode(querySchema);
CacheMode? cacheMode = (querySchema.cachemodeSpecified)
- ? CacheModeConverter.GetCacheMode(querySchema.cachemode)
+ ? querySchema.cachemode.ToCacheMode()
: null;
IDictionary<string,string> parameterTypes = new LinkedHashMap<string,string>();
Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/NamedSQLQueryBinder.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/NamedSQLQueryBinder.cs 2010-01-05 22:16:33 UTC (rev 4900)
+++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/NamedSQLQueryBinder.cs 2010-01-05 22:56:37 UTC (rev 4901)
@@ -29,7 +29,7 @@
FlushMode flushMode = FlushModeConverter.GetFlushMode(querySchema);
CacheMode? cacheMode = (querySchema.cachemodeSpecified)
- ? CacheModeConverter.GetCacheMode(querySchema.cachemode)
+ ? querySchema.cachemode.ToCacheMode()
: null;
IDictionary<string,string> parameterTypes = new LinkedHashMap<string,string>();
Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/RootClassBinder.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/RootClassBinder.cs 2010-01-05 22:16:33 UTC (rev 4900)
+++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/RootClassBinder.cs 2010-01-05 22:56:37 UTC (rev 4901)
@@ -259,7 +259,7 @@
{
if (cacheSchema != null)
{
- rootClass.CacheConcurrencyStrategy = GetXmlEnumAttribute(cacheSchema.usage);
+ rootClass.CacheConcurrencyStrategy = cacheSchema.usage.ToCacheConcurrencyStrategy();
rootClass.CacheRegionName = cacheSchema.region;
}
}
Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2010-01-05 22:16:33 UTC (rev 4900)
+++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2010-01-05 22:56:37 UTC (rev 4901)
@@ -881,7 +881,6 @@
<Compile Include="Cfg\MappingSchema\MappingDocumentParser.cs" />
<Compile Include="Cfg\XmlHbmBinding\AuxiliaryDatabaseObjectFactory.cs" />
<Compile Include="Cfg\MappingSchema\HbmFilterDef.cs" />
- <Compile Include="Cfg\XmlHbmBinding\CacheModeConverter.cs" />
<Compile Include="Cfg\XmlHbmBinding\ClassCompositeIdBinder.cs" />
<Compile Include="Cfg\XmlHbmBinding\ClassDiscriminatorBinder.cs" />
<Compile Include="Cfg\XmlHbmBinding\ClassIdBinder.cs" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2010-01-06 05:08:29
|
Revision: 4904
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4904&view=rev
Author: fabiomaulo
Date: 2010-01-06 05:08:17 +0000 (Wed, 06 Jan 2010)
Log Message:
-----------
- Refactoring
- removed unused code
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Cfg/ClassExtractor.cs
trunk/nhibernate/src/NHibernate/Cfg/Configuration.cs
trunk/nhibernate/src/NHibernate/Cfg/NamedXmlDocument.cs
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/Binder.cs
trunk/nhibernate/src/NHibernate/NHibernate.csproj
Removed Paths:
-------------
trunk/nhibernate/src/NHibernate/Util/XmlHelper.cs
Modified: trunk/nhibernate/src/NHibernate/Cfg/ClassExtractor.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/ClassExtractor.cs 2010-01-06 04:00:10 UTC (rev 4903)
+++ trunk/nhibernate/src/NHibernate/Cfg/ClassExtractor.cs 2010-01-06 05:08:17 UTC (rev 4904)
@@ -1,8 +1,8 @@
using System.Xml;
-using NHibernate.Cfg.XmlHbmBinding;
+using System.Linq;
using NHibernate.Util;
using System.Collections.Generic;
-using Iesi.Collections.Generic;
+using NHibernate.Cfg.MappingSchema;
namespace NHibernate.Cfg
{
@@ -59,8 +59,7 @@
public override bool Equals(object obj)
{
- ClassEntry that = obj as ClassEntry;
- return Equals(that);
+ return Equals(obj as ClassEntry);
}
public bool Equals(ClassEntry obj)
@@ -88,40 +87,19 @@
/// </summary>
/// <param name="document">A validated <see cref="XmlDocument"/> representing
/// a mapping file.</param>
- public static ICollection<ClassEntry> GetClassEntries(XmlDocument document)
+ public static ICollection<ClassEntry> GetClassEntries(HbmMapping document)
{
- // TODO this should be extracted into a utility method since there's similar
- // code in Configuration
- XmlNamespaceManager nsmgr = new XmlNamespaceManager(document.NameTable);
- nsmgr.AddNamespace(HbmConstants.nsPrefix, Binder.MappingSchemaXMLNS);
-
// Since the document is validated, no error checking is done in this method.
- HashedSet<ClassEntry> classEntries = new HashedSet<ClassEntry>();
+ var classEntries = new HashSet<ClassEntry>();
- XmlNode root = document.DocumentElement;
+ string assembly = document.assembly;
+ string @namespace = document.@namespace;
- string assembly = XmlHelper.GetAttributeValue(root, "assembly");
- string @namespace = XmlHelper.GetAttributeValue(root, "namespace");
+ classEntries.UnionWith(document.RootClasses.Select(c=> new ClassEntry(null, c.Name, c.EntityName, assembly, @namespace)));
+ classEntries.UnionWith(document.SubClasses.Select(c => new ClassEntry(c.extends, c.Name, c.EntityName, assembly, @namespace)));
+ classEntries.UnionWith(document.JoinedSubclasses.Select(c => new ClassEntry(c.extends, c.Name, c.EntityName, assembly, @namespace)));
+ classEntries.UnionWith(document.UnionSubclasses.Select(c => new ClassEntry(c.extends, c.Name, c.EntityName, assembly, @namespace)));
- XmlNodeList classNodes = document.SelectNodes(
- "//" + HbmConstants.nsClass +
- "|//" + HbmConstants.nsSubclass +
- "|//" + HbmConstants.nsJoinedSubclass +
- "|//" + HbmConstants.nsUnionSubclass,
- nsmgr
- );
-
- if (classNodes != null)
- {
- foreach (XmlNode classNode in classNodes)
- {
- string name = XmlHelper.GetAttributeValue(classNode, "name");
- string extends = XmlHelper.GetAttributeValue(classNode, "extends");
- string entityName = XmlHelper.GetAttributeValue(classNode, "entity-name");
- classEntries.Add(new ClassEntry(extends, name, entityName, assembly, @namespace));
- }
- }
-
return classEntries;
}
}
Modified: trunk/nhibernate/src/NHibernate/Cfg/Configuration.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/Configuration.cs 2010-01-06 04:00:10 UTC (rev 4903)
+++ trunk/nhibernate/src/NHibernate/Cfg/Configuration.cs 2010-01-06 05:08:17 UTC (rev 4904)
@@ -8,7 +8,6 @@
using System.Text;
using System.Xml;
using System.Xml.Schema;
-using System.Xml.Serialization;
using Iesi.Collections;
using Iesi.Collections.Generic;
using log4net;
@@ -494,22 +493,7 @@
/// <param name="doc">The NamedXmlDocument that contains the <b>validated</b> mapping XML file.</param>
private void AddValidatedDocument(NamedXmlDocument doc)
{
- HbmMapping mappingMeta = null;
- try
- {
- // TODO : The mappingMeta should be the property of NamedXmlDocument
- // A validated document IS a deserialized doc and we don't need to deserialize it more than one time.
- using (var reader = new StringReader(doc.Document.DocumentElement.OuterXml))
- {
- mappingMeta = (HbmMapping) new XmlSerializer(typeof (HbmMapping)).Deserialize(reader);
- }
- }
- catch (Exception e)
- {
- string nameFormatted = doc.Name ?? "(unknown)";
- LogAndThrow(new MappingException("Could not compile the mapping document: " + nameFormatted, e));
- }
- AddDeserializedMapping(mappingMeta, doc.Name);
+ AddDeserializedMapping(doc.Document, doc.Name);
}
/// <summary>
@@ -1762,11 +1746,21 @@
hbmDocument.Load(reader);
return new NamedXmlDocument(name, hbmDocument);
}
+ catch(MappingException)
+ {
+ throw;
+ }
+ catch (Exception e)
+ {
+ string nameFormatted = name ?? "(unknown)";
+ LogAndThrow(new MappingException("Could not compile the mapping document: " + nameFormatted, e));
+ }
finally
{
currentDocumentName = null;
}
}
+ return null;
}
/// <summary>
Modified: trunk/nhibernate/src/NHibernate/Cfg/NamedXmlDocument.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/NamedXmlDocument.cs 2010-01-06 04:00:10 UTC (rev 4903)
+++ trunk/nhibernate/src/NHibernate/Cfg/NamedXmlDocument.cs 2010-01-06 05:08:17 UTC (rev 4904)
@@ -1,16 +1,31 @@
+using System;
+using System.IO;
using System.Xml;
+using System.Xml.Serialization;
+using NHibernate.Cfg.MappingSchema;
namespace NHibernate.Cfg
{
public class NamedXmlDocument
{
private readonly string name;
- private readonly XmlDocument document;
+ private readonly HbmMapping document;
public NamedXmlDocument(string name, XmlDocument document)
{
+ if (document == null)
+ {
+ throw new ArgumentNullException("document");
+ }
this.name = name;
- this.document = document;
+ if (document.DocumentElement == null)
+ {
+ throw new MappingException("Empty XML document:" + name);
+ }
+ using (var reader = new StringReader(document.DocumentElement.OuterXml))
+ {
+ this.document = (HbmMapping)new XmlSerializer(typeof(HbmMapping)).Deserialize(reader);
+ }
}
public string Name
@@ -18,7 +33,7 @@
get { return name; }
}
- public XmlDocument Document
+ public HbmMapping Document
{
get { return document; }
}
Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/Binder.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/Binder.cs 2010-01-06 04:00:10 UTC (rev 4903)
+++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/Binder.cs 2010-01-06 05:08:17 UTC (rev 4904)
@@ -10,9 +10,6 @@
{
public abstract class Binder
{
- /// <summary>The XML Namespace for the nhibernate-mapping</summary>
- public const string MappingSchemaXMLNS = "urn:nhibernate-mapping-2.2";
-
protected static readonly ILog log = LogManager.GetLogger(typeof (Binder));
protected static readonly IDictionary<string, MetaAttribute> EmptyMeta =
Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2010-01-06 04:00:10 UTC (rev 4903)
+++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2010-01-06 05:08:17 UTC (rev 4904)
@@ -1487,7 +1487,6 @@
<Compile Include="Util\WeakHashtable.cs">
<SubType>Code</SubType>
</Compile>
- <Compile Include="Util\XmlHelper.cs" />
<Compile Include="Properties\XmlAccessor.cs" />
<EmbeddedResource Include="nhibernate-configuration.xsd">
<SubType>
Deleted: trunk/nhibernate/src/NHibernate/Util/XmlHelper.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Util/XmlHelper.cs 2010-01-06 04:00:10 UTC (rev 4903)
+++ trunk/nhibernate/src/NHibernate/Util/XmlHelper.cs 2010-01-06 05:08:17 UTC (rev 4904)
@@ -1,29 +0,0 @@
-using System;
-using System.Xml;
-
-namespace NHibernate.Util
-{
- public class XmlHelper
- {
- public static string GetAttributeValue(XmlNode node, string attributeName)
- {
- XmlAttribute attribute = node.Attributes[attributeName];
- if (attribute == null)
- {
- return null;
- }
- return attribute.Value;
- }
-
- public static string ElementTextTrim(XmlNode node, string elementName, XmlNamespaceManager nsmgr)
- {
- XmlNode subNode = node.SelectSingleNode(elementName, nsmgr);
- if (subNode == null)
- {
- return null;
- }
-
- return subNode.InnerText.Trim();
- }
- }
-}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|