From: <fab...@us...> - 2009-05-12 15:29:39
|
Revision: 4283 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4283&view=rev Author: fabiomaulo Date: 2009-05-12 15:29:32 +0000 (Tue, 12 May 2009) Log Message: ----------- Fixing ignored mappings nodes Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/Binder.cs trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/CollectionBinder.cs trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/RootClassBinder.cs trunk/nhibernate/src/NHibernate/Mapping/Component.cs trunk/nhibernate/src/NHibernate/Mapping/IMetaAttributable.cs trunk/nhibernate/src/NHibernate/Mapping/PersistentClass.cs trunk/nhibernate/src/NHibernate/Mapping/Property.cs trunk/nhibernate/src/NHibernate/NHibernate.csproj trunk/nhibernate/src/NHibernate.Test/MappingTest/NonReflectiveBinderFixture.cs trunk/nhibernate/src/NHibernate.Test/MappingTest/Wicked.cs trunk/nhibernate/src/NHibernate.Test/MappingTest/Wicked.hbm.xml Added Paths: ----------- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmTimestamp.cs trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmVersion.cs Added: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmTimestamp.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmTimestamp.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmTimestamp.cs 2009-05-12 15:29:32 UTC (rev 4283) @@ -0,0 +1,10 @@ +namespace NHibernate.Cfg.MappingSchema +{ + partial class HbmTimestamp : AbstractDecoratable + { + protected override HbmMeta[] GetMetadataField() + { + return meta; + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmVersion.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmVersion.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmVersion.cs 2009-05-12 15:29:32 UTC (rev 4283) @@ -0,0 +1,10 @@ +namespace NHibernate.Cfg.MappingSchema +{ + partial class HbmVersion : AbstractDecoratable + { + protected override HbmMeta[] GetMetadataField() + { + return meta; + } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/Binder.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/Binder.cs 2009-05-12 04:53:16 UTC (rev 4282) +++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/Binder.cs 2009-05-12 15:29:32 UTC (rev 4283) @@ -196,5 +196,47 @@ } return map; } + + public static IDictionary<string, MetaAttribute> GetMetas(XmlNodeList nodes, IDictionary<string, MetaAttribute> inheritedMeta) + { + return GetMetas(nodes, inheritedMeta, false); + } + + public static IDictionary<string, MetaAttribute> GetMetas(XmlNodeList nodes, IDictionary<string, MetaAttribute> inheritedMeta, bool onlyInheritable) + { + var map = new Dictionary<string, MetaAttribute>(inheritedMeta); + foreach (XmlNode metaNode in nodes) + { + if(metaNode.Name != "meta") + { + continue; + } + var inheritableValue = GetAttributeValue(metaNode, "inherit"); + bool inheritable = inheritableValue != null ? IsTrue(inheritableValue) : false; + if (onlyInheritable & !inheritable) + { + continue; + } + string name = GetAttributeValue(metaNode, "attribute"); + + MetaAttribute meta; + MetaAttribute inheritedAttribute; + map.TryGetValue(name, out meta); + inheritedMeta.TryGetValue(name, out inheritedAttribute); + if (meta == null) + { + meta = new MetaAttribute(name); + map[name] = meta; + } + else if (meta == inheritedAttribute) + { + meta = new MetaAttribute(name); + map[name] = meta; + } + meta.AddValue(metaNode.InnerText); + } + return map; + } + } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs 2009-05-12 04:53:16 UTC (rev 4282) +++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs 2009-05-12 15:29:32 UTC (rev 4283) @@ -54,8 +54,8 @@ CollectionBinder collectionBinder = new CollectionBinder(this); if (collectionBinder.CanCreate(name)) { - Mapping.Collection collection = collectionBinder.Create(name, subnode, entityName, - propertyName, model, model.MappedClass); + Mapping.Collection collection = collectionBinder.Create(name, subnode, entityName, propertyName, model, + model.MappedClass, inheritedMetas); mappings.AddCollection(collection); value = collection; @@ -86,13 +86,13 @@ // 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); + 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); + BindJoin(subnode, join, inheritedMetas); model.AddJoin(join); } else if ("subclass".Equals(name)) @@ -125,7 +125,7 @@ if (value != null) { - Property property = CreateProperty(value, propertyName, model.ClassName, subnode); + Property property = CreateProperty(value, propertyName, model.ClassName, subnode, inheritedMetas); if (!mutable) property.IsUpdateable = false; if (naturalId) @@ -296,7 +296,7 @@ return null; } - private void BindJoin(XmlNode node, Join join) + private void BindJoin(XmlNode node, Join join, IDictionary<string, MetaAttribute> inheritedMetas) { PersistentClass persistentClass = join.PersistentClass; String path = persistentClass.EntityName; @@ -351,8 +351,9 @@ var collectionBinder = new CollectionBinder(this); if (collectionBinder.CanCreate(name)) { - Mapping.Collection collection = collectionBinder.Create(name, subnode, persistentClass.EntityName, - propertyName, persistentClass, persistentClass.MappedClass); + Mapping.Collection collection = collectionBinder.Create(name, subnode, persistentClass.EntityName, propertyName, + persistentClass, persistentClass.MappedClass, + inheritedMetas); mappings.AddCollection(collection); value = collection; @@ -378,13 +379,14 @@ string subpath = StringHelper.Qualify(path, propertyName); value = new Component(join); BindComponent(subnode, (Component) value, join.PersistentClass.MappedClass, join.PersistentClass.ClassName, - propertyName, subpath, true); + propertyName, subpath, true, inheritedMetas); break; } } if (value != null) { - Mapping.Property prop = CreateProperty(value, propertyName, persistentClass.MappedClass.AssemblyQualifiedName, subnode); + var prop = CreateProperty(value, propertyName, persistentClass.MappedClass.AssemblyQualifiedName, subnode, + inheritedMetas); prop.IsOptional = join.IsOptional; join.AddProperty(prop); } @@ -543,12 +545,16 @@ } protected void BindComponent(XmlNode node, Component model, System.Type reflectedClass, - string className, string parentProperty, string path, bool isNullable) + string className, string parentProperty, string path, bool isNullable, + IDictionary<string, MetaAttribute> inheritedMetas) { bool isIdentifierMapper = false; model.RoleName = path; + inheritedMetas = GetMetas(node.SelectNodes(HbmConstants.nsMeta, namespaceManager), inheritedMetas); + model.MetaAttributes = inheritedMetas; + XmlAttribute classNode = node.Attributes["class"]; if (classNode != null) @@ -595,8 +601,8 @@ if (binder.CanCreate(name)) { - Mapping.Collection collection = binder.Create(name, subnode, className, - subpath, model.Owner, model.ComponentClass); + Mapping.Collection collection = binder.Create(name, subnode, className, subpath, model.Owner, model.ComponentClass, + inheritedMetas); mappings.AddCollection(collection); value = collection; @@ -629,14 +635,14 @@ : GetPropertyType(subnode, model.ComponentClass, propertyName); value = new Component(model); - BindComponent(subnode, (Component) value, subreflectedClass, className, propertyName, subpath, isNullable); + BindComponent(subnode, (Component) value, subreflectedClass, className, propertyName, subpath, isNullable, inheritedMetas); } else if ("parent".Equals(name)) model.ParentProperty = propertyName; if (value != null) { - Property property = CreateProperty(value, propertyName, model.ComponentClassName, subnode); + Property property = CreateProperty(value, propertyName, model.ComponentClassName, subnode, inheritedMetas); if (isIdentifierMapper) { property.IsInsertable = false; @@ -648,7 +654,7 @@ } protected Property CreateProperty(IValue value, string propertyName, string className, - XmlNode subnode) + XmlNode subnode, IDictionary<string, MetaAttribute> inheritedMetas) { if (string.IsNullOrEmpty(propertyName)) { @@ -668,14 +674,13 @@ } value.CreateForeignKey(); - Property prop = new Property(); - prop.Value = value; - BindProperty(subnode, prop); + var prop = new Property {Value = value}; + BindProperty(subnode, prop, inheritedMetas); return prop; } - protected void BindProperty(XmlNode node, Mapping.Property property) + protected void BindProperty(XmlNode node, Property property, IDictionary<string, MetaAttribute> inheritedMetas) { string propName = XmlHelper.GetAttributeValue(node, "name"); property.Name = propName; @@ -742,7 +747,7 @@ log.Debug(msg); } - property.MetaAttributes = GetMetas(node); + property.MetaAttributes = GetMetas(node.SelectNodes(HbmConstants.nsMeta, namespaceManager), inheritedMetas); } protected static PropertyGeneration ParsePropertyGeneration(string name) @@ -946,25 +951,6 @@ model.PropertyName = node.Attributes["name"].Value; } - protected IDictionary<string, MetaAttribute> GetMetas(XmlNode node) - { - Dictionary<string, MetaAttribute> map = new Dictionary<string, MetaAttribute>(); - - foreach (XmlNode metaNode in node.SelectNodes(HbmConstants.nsMeta, namespaceManager)) - { - string name = metaNode.Attributes["attribute"].Value; - MetaAttribute meta; - if (!map.TryGetValue(name, out meta)) - { - meta = new MetaAttribute(name); - map[name] = meta; - } - meta.AddValue(metaNode.InnerText); - } - - return map; - } - protected System.Type GetPropertyType(XmlNode definingNode, System.Type containingType, string propertyName) { if (definingNode.Attributes["class"] != null) Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/CollectionBinder.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/CollectionBinder.cs 2009-05-12 04:53:16 UTC (rev 4282) +++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/CollectionBinder.cs 2009-05-12 15:29:32 UTC (rev 4283) @@ -38,65 +38,65 @@ } public Mapping.Collection Create(string xmlTagName, XmlNode node, string className, - string path, PersistentClass owner, System.Type containingType) + string path, PersistentClass owner, System.Type containingType, IDictionary<string, MetaAttribute> inheritedMetas) { CreateCollectionCommand command = createCollectionCommands[xmlTagName]; - return command(node, className, path, owner, containingType); + return command(node, className, path, owner, containingType, inheritedMetas); } private Mapping.Collection CreateMap(XmlNode node, string prefix, string path, - PersistentClass owner, System.Type containingType) + PersistentClass owner, System.Type containingType, IDictionary<string, MetaAttribute> inheritedMetas) { Map map = new Map(owner); - BindCollection(node, map, prefix, path, containingType); + BindCollection(node, map, prefix, path, containingType, inheritedMetas); return map; } private Mapping.Collection CreateSet(XmlNode node, string prefix, string path, - PersistentClass owner, System.Type containingType) + PersistentClass owner, System.Type containingType, IDictionary<string, MetaAttribute> inheritedMetas) { Set setCollection = new Set(owner); - BindCollection(node, setCollection, prefix, path, containingType); + BindCollection(node, setCollection, prefix, path, containingType, inheritedMetas); return setCollection; } private Mapping.Collection CreateList(XmlNode node, string prefix, string path, - PersistentClass owner, System.Type containingType) + PersistentClass owner, System.Type containingType, IDictionary<string, MetaAttribute> inheritedMetas) { List list = new List(owner); - BindCollection(node, list, prefix, path, containingType); + BindCollection(node, list, prefix, path, containingType, inheritedMetas); return list; } private Mapping.Collection CreateBag(XmlNode node, string prefix, string path, - PersistentClass owner, System.Type containingType) + PersistentClass owner, System.Type containingType, IDictionary<string, MetaAttribute> inheritedMetas) { Bag bag = new Bag(owner); - BindCollection(node, bag, prefix, path, containingType); + BindCollection(node, bag, prefix, path, containingType, inheritedMetas); return bag; } private Mapping.Collection CreateIdentifierBag(XmlNode node, string prefix, string path, - PersistentClass owner, System.Type containingType) + PersistentClass owner, System.Type containingType, IDictionary<string, MetaAttribute> inheritedMetas) { IdentifierBag bag = new IdentifierBag(owner); - BindCollection(node, bag, prefix, path, containingType); + BindCollection(node, bag, prefix, path, containingType, inheritedMetas); return bag; } private Mapping.Collection CreateArray(XmlNode node, string prefix, string path, - PersistentClass owner, System.Type containingType) + PersistentClass owner, System.Type containingType, IDictionary<string, MetaAttribute> inheritedMetas) { Array array = new Array(owner); - BindArray(node, array, prefix, path, containingType); + BindArray(node, array, prefix, path, containingType, inheritedMetas); return array; } private Mapping.Collection CreatePrimitiveArray(XmlNode node, string prefix, string path, - PersistentClass owner, System.Type containingType) + PersistentClass owner, System.Type containingType, IDictionary<string, MetaAttribute> inheritedMetas) { PrimitiveArray array = new PrimitiveArray(owner); - BindArray(node, array, prefix, path, containingType); + BindArray(node, array, prefix, path, containingType,inheritedMetas); return array; } @@ -105,7 +105,7 @@ /// was added in NH to allow for reflection related to generic types. /// </remarks> private void BindCollection(XmlNode node, Mapping.Collection model, string className, - string path, System.Type containingType) + string path, System.Type containingType, IDictionary<string, MetaAttribute> inheritedMetas) { // ROLENAME model.Role = StringHelper.Qualify(className, path); @@ -253,19 +253,19 @@ //set up second pass if (model is List) - AddListSecondPass(node, (List)model); + AddListSecondPass(node, (List)model, inheritedMetas); else if (model is Map) - AddMapSecondPass(node, (Map)model); + AddMapSecondPass(node, (Map)model, inheritedMetas); else if (model is Set) - AddSetSecondPass(node, (Set)model); + AddSetSecondPass(node, (Set)model, inheritedMetas); else if (model is IdentifierCollection) - AddIdentifierCollectionSecondPass(node, (IdentifierCollection)model); + AddIdentifierCollectionSecondPass(node, (IdentifierCollection)model, inheritedMetas); else - AddCollectionSecondPass(node, model); + AddCollectionSecondPass(node, model, inheritedMetas); foreach (XmlNode filter in node.SelectNodes(HbmConstants.nsFilter, namespaceManager)) ParseFilter(filter, model); @@ -284,9 +284,9 @@ /// Called for arrays and primitive arrays /// </remarks> private void BindArray(XmlNode node, Array model, string prefix, string path, - System.Type containingType) + System.Type containingType, IDictionary<string, MetaAttribute> inheritedMetas) { - BindCollection(node, model, prefix, path, containingType); + BindCollection(node, model, prefix, path, containingType, inheritedMetas); XmlAttribute att = node.Attributes["element-class"]; @@ -327,52 +327,52 @@ } } - private void AddListSecondPass(XmlNode node, List model) + private void AddListSecondPass(XmlNode node, List model, IDictionary<string, MetaAttribute> inheritedMetas) { mappings.AddSecondPass(delegate(IDictionary<string, PersistentClass> persistentClasses) { PreCollectionSecondPass(model); - BindListSecondPass(node, model, persistentClasses); + BindListSecondPass(node, model, persistentClasses, inheritedMetas); PostCollectionSecondPass(model); }); } - private void AddMapSecondPass(XmlNode node, Map model) + private void AddMapSecondPass(XmlNode node, Map model, IDictionary<string, MetaAttribute> inheritedMetas) { mappings.AddSecondPass(delegate(IDictionary<string, PersistentClass> persistentClasses) { PreCollectionSecondPass(model); - BindMapSecondPass(node, model, persistentClasses); + BindMapSecondPass(node, model, persistentClasses, inheritedMetas); PostCollectionSecondPass(model); }); } - private void AddSetSecondPass(XmlNode node, Set model) + private void AddSetSecondPass(XmlNode node, Set model, IDictionary<string, MetaAttribute> inheritedMetas) { mappings.AddSecondPass(delegate(IDictionary<string, PersistentClass> persistentClasses) { PreCollectionSecondPass(model); - BindSetSecondPass(node, model, persistentClasses); + BindSetSecondPass(node, model, persistentClasses, inheritedMetas); PostCollectionSecondPass(model); }); } - private void AddIdentifierCollectionSecondPass(XmlNode node, IdentifierCollection model) + private void AddIdentifierCollectionSecondPass(XmlNode node, IdentifierCollection model, IDictionary<string, MetaAttribute> inheritedMetas) { mappings.AddSecondPass(delegate(IDictionary<string, PersistentClass> persistentClasses) { PreCollectionSecondPass(model); - BindIdentifierCollectionSecondPass(node, model, persistentClasses); + BindIdentifierCollectionSecondPass(node, model, persistentClasses, inheritedMetas); PostCollectionSecondPass(model); }); } - private void AddCollectionSecondPass(XmlNode node, Mapping.Collection model) + private void AddCollectionSecondPass(XmlNode node, Mapping.Collection model, IDictionary<string, MetaAttribute> inheritedMetas) { mappings.AddSecondPass(delegate(IDictionary<string, PersistentClass> persistentClasses) { PreCollectionSecondPass(model); - BindCollectionSecondPass(node, model, persistentClasses); + BindCollectionSecondPass(node, model, persistentClasses, inheritedMetas); PostCollectionSecondPass(model); }); } @@ -436,9 +436,9 @@ } private void BindListSecondPass(XmlNode node, List model, - IDictionary<string, PersistentClass> persistentClasses) + IDictionary<string, PersistentClass> persistentClasses, IDictionary<string, MetaAttribute> inheritedMetas) { - BindCollectionSecondPass(node, model, persistentClasses); + BindCollectionSecondPass(node, model, persistentClasses, inheritedMetas); XmlNode subnode = node.SelectSingleNode(HbmConstants.nsListIndex, namespaceManager); if (subnode == null) { subnode = node.SelectSingleNode(HbmConstants.nsIndex, namespaceManager); } @@ -459,9 +459,9 @@ } private void BindIdentifierCollectionSecondPass(XmlNode node, IdentifierCollection model, - IDictionary<string, PersistentClass> persitentClasses) + IDictionary<string, PersistentClass> persitentClasses, IDictionary<string, MetaAttribute> inheritedMetas) { - BindCollectionSecondPass(node, model, persitentClasses); + BindCollectionSecondPass(node, model, persitentClasses, inheritedMetas); XmlNode subnode = node.SelectSingleNode(HbmConstants.nsCollectionId, namespaceManager); SimpleValue id = new SimpleValue(model.CollectionTable); @@ -481,9 +481,9 @@ } private void BindSetSecondPass(XmlNode node, Set model, - IDictionary<string, PersistentClass> persistentClasses) + IDictionary<string, PersistentClass> persistentClasses, IDictionary<string, MetaAttribute> inheritedMetas) { - BindCollectionSecondPass(node, model, persistentClasses); + BindCollectionSecondPass(node, model, persistentClasses, inheritedMetas); if (!model.IsOneToMany) model.CreatePrimaryKey(); @@ -492,13 +492,10 @@ /// <summary> /// Called for Maps /// </summary> - /// <param name="node"></param> - /// <param name="model"></param> - /// <param name="persistentClasses"></param> private void BindMapSecondPass(XmlNode node, Map model, - IDictionary<string, PersistentClass> persistentClasses) + IDictionary<string, PersistentClass> persistentClasses, IDictionary<string, MetaAttribute> inheritedMetas) { - BindCollectionSecondPass(node, model, persistentClasses); + BindCollectionSecondPass(node, model, persistentClasses, inheritedMetas); foreach (XmlNode subnode in node.ChildNodes) { @@ -525,7 +522,7 @@ else if ("composite-index".Equals(name) || "composite-map-key".Equals(name)) { Component component = new Component(model); - BindComponent(subnode, component, null, null, null, model.Role + ".index", model.IsOneToMany); + BindComponent(subnode, component, null, null, null, model.Role + ".index", model.IsOneToMany,inheritedMetas); model.Index = component; } else if ("index-many-to-any".Equals(name)) @@ -541,7 +538,7 @@ /// Called for all collections /// </remarks> private void BindCollectionSecondPass(XmlNode node, Mapping.Collection model, - IDictionary<string, PersistentClass> persistentClasses) + IDictionary<string, PersistentClass> persistentClasses, IDictionary<string, MetaAttribute> inheritedMetas) { if (model.IsOneToMany) { @@ -614,7 +611,7 @@ { Component element = new Component(model); model.Element = element; - BindComponent(subnode, element, null, null, null, model.Role+ ".element", true); + BindComponent(subnode, element, null, null, null, model.Role+ ".element", true, inheritedMetas); } else if ("many-to-any".Equals(name)) { @@ -673,6 +670,6 @@ } private delegate Mapping.Collection CreateCollectionCommand(XmlNode node, string className, - string path, PersistentClass owner, System.Type containingType); + 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-05-12 04:53:16 UTC (rev 4282) +++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/RootClassBinder.cs 2009-05-12 15:29:32 UTC (rev 4283) @@ -48,8 +48,8 @@ new ClassIdBinder(this).BindId(classSchema.Id, rootClass, table); new ClassCompositeIdBinder(this).BindCompositeId(classSchema.CompositeId, rootClass); new ClassDiscriminatorBinder(this).BindDiscriminator(classSchema.discriminator, rootClass, table); - BindTimestamp(classSchema.Timestamp, rootClass, table); - BindVersion(classSchema.Version, rootClass, table); + BindTimestamp(classSchema.Timestamp, rootClass, table, inheritedMetas); + BindVersion(classSchema.Version, rootClass, table, inheritedMetas); rootClass.CreatePrimaryKey(dialect); @@ -65,7 +65,7 @@ return mappings.NamingStrategy.TableName(classSchema.table.Trim()); } - private void BindTimestamp(HbmTimestamp timestampSchema, PersistentClass rootClass, Table table) + private void BindTimestamp(HbmTimestamp timestampSchema, PersistentClass rootClass, Table table, IDictionary<string, MetaAttribute> inheritedMetas) { if (timestampSchema == null) return; @@ -78,8 +78,8 @@ if (!simpleValue.IsTypeSpecified) simpleValue.TypeName = NHibernateUtil.Timestamp.Name; - Mapping.Property property = new Mapping.Property(simpleValue); - BindProperty(timestampSchema, property); + var property = new Property(simpleValue); + BindProperty(timestampSchema, property, inheritedMetas); // for version properties marked as being generated, make sure they are "always" // generated; "insert" is invalid. This is dis-allowed by the schema, but just to make @@ -128,7 +128,7 @@ column.SqlType = null; } - private void BindProperty(HbmTimestamp timestampSchema, Mapping.Property property) + private void BindProperty(HbmTimestamp timestampSchema, Property property, IDictionary<string, MetaAttribute> inheritedMetas) { property.Name = timestampSchema.name; @@ -158,7 +158,7 @@ property.IsUpdateable = false; } - property.MetaAttributes = new Dictionary<string, MetaAttribute>(); + property.MetaAttributes = GetMetas(timestampSchema, inheritedMetas); LogMappedProperty(property); } @@ -178,7 +178,7 @@ } } - private void BindVersion(HbmVersion versionSchema, PersistentClass rootClass, Table table) + private void BindVersion(HbmVersion versionSchema, PersistentClass rootClass, Table table, IDictionary<string, MetaAttribute> inheritedMetas) { if (versionSchema == null) return; @@ -190,8 +190,8 @@ if (!simpleValue.IsTypeSpecified) simpleValue.TypeName = NHibernateUtil.Int32.Name; - Mapping.Property property = new Mapping.Property(simpleValue); - BindProperty(versionSchema, property); + var property = new Property(simpleValue); + BindProperty(versionSchema, property, inheritedMetas); // for version properties marked as being generated, make sure they are "always" // generated; "insert" is invalid. This is dis-allowed by the schema, but just to make @@ -249,7 +249,7 @@ } } - private void BindProperty(HbmVersion versionSchema, Mapping.Property property) + private void BindProperty(HbmVersion versionSchema, Property property, IDictionary<string, MetaAttribute> inheritedMetas) { property.Name = versionSchema.name; @@ -279,7 +279,7 @@ property.IsUpdateable = false; } - property.MetaAttributes = new Dictionary<string, MetaAttribute>(); + property.MetaAttributes = GetMetas(versionSchema, inheritedMetas); LogMappedProperty(property); } Modified: trunk/nhibernate/src/NHibernate/Mapping/Component.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Mapping/Component.cs 2009-05-12 04:53:16 UTC (rev 4282) +++ trunk/nhibernate/src/NHibernate/Mapping/Component.cs 2009-05-12 15:29:32 UTC (rev 4283) @@ -318,5 +318,7 @@ { return GetType().FullName + '(' + StringHelper.CollectionToString(properties) + ')'; } + + public IDictionary<string, MetaAttribute> MetaAttributes { get; set; } } } Modified: trunk/nhibernate/src/NHibernate/Mapping/IMetaAttributable.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Mapping/IMetaAttributable.cs 2009-05-12 04:53:16 UTC (rev 4282) +++ trunk/nhibernate/src/NHibernate/Mapping/IMetaAttributable.cs 2009-05-12 15:29:32 UTC (rev 4283) @@ -13,8 +13,8 @@ /// <summary> /// Retrieve the <see cref="MetaAttribute"/> /// </summary> - /// <param name="name">The attribute name</param> + /// <param name="attributeName">The attribute name</param> /// <returns>The <see cref="MetaAttribute"/> if exists; null otherwise</returns> - MetaAttribute GetMetaAttribute(string name); + MetaAttribute GetMetaAttribute(string attributeName); } } Modified: trunk/nhibernate/src/NHibernate/Mapping/PersistentClass.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Mapping/PersistentClass.cs 2009-05-12 04:53:16 UTC (rev 4282) +++ trunk/nhibernate/src/NHibernate/Mapping/PersistentClass.cs 2009-05-12 15:29:32 UTC (rev 4283) @@ -969,12 +969,12 @@ } } - public MetaAttribute GetMetaAttribute(string name) + public MetaAttribute GetMetaAttribute(string attributeName) { if (metaAttributes == null) return null; MetaAttribute result; - metaAttributes.TryGetValue(name, out result); + metaAttributes.TryGetValue(attributeName, out result); return result; } Modified: trunk/nhibernate/src/NHibernate/Mapping/Property.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Mapping/Property.cs 2009-05-12 04:53:16 UTC (rev 4282) +++ trunk/nhibernate/src/NHibernate/Mapping/Property.cs 2009-05-12 15:29:32 UTC (rev 4283) @@ -204,9 +204,11 @@ set { metaAttributes = value; } } - public MetaAttribute GetMetaAttribute(string name) + public MetaAttribute GetMetaAttribute(string attributeName) { - return metaAttributes[name]; + MetaAttribute result; + metaAttributes.TryGetValue(attributeName, out result); + return result; } public bool IsValid(IMapping mapping) Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj =================================================================== --- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-05-12 04:53:16 UTC (rev 4282) +++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-05-12 15:29:32 UTC (rev 4283) @@ -455,6 +455,8 @@ <Compile Include="Bytecode\ProxyFactoryFactoryNotConfiguredException.cs" /> <Compile Include="Bytecode\UnableToLoadProxyFactoryFactoryException.cs" /> <Compile Include="Cfg\MappingSchema\AbstractDecoratable.cs" /> + <Compile Include="Cfg\MappingSchema\HbmTimestamp.cs" /> + <Compile Include="Cfg\MappingSchema\HbmVersion.cs" /> <Compile Include="Cfg\MappingSchema\IDecoratable.cs" /> <Compile Include="Criterion\IPropertyProjection.cs" /> <Compile Include="Dialect\MsSql2008Dialect.cs" /> Modified: trunk/nhibernate/src/NHibernate.Test/MappingTest/NonReflectiveBinderFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/MappingTest/NonReflectiveBinderFixture.cs 2009-05-12 04:53:16 UTC (rev 4282) +++ trunk/nhibernate/src/NHibernate.Test/MappingTest/NonReflectiveBinderFixture.cs 2009-05-12 15:29:32 UTC (rev 4283) @@ -36,6 +36,43 @@ Assert.That(m, Is.Not.Null); Assert.That(cm.GetMetaAttribute("global"), Is.Not.Null); Assert.That(cm.GetMetaAttribute("globalnoinherit"), Is.Null); + + MetaAttribute metaAttribute = cm.GetMetaAttribute("implements"); + Assert.That(metaAttribute, Is.Not.Null); + Assert.That(metaAttribute.Name, Is.EqualTo("implements")); + Assert.That(metaAttribute.IsMultiValued); + var values = metaAttribute.Values; + Assert.That(values.Count, Is.EqualTo(3)); + Assert.That(values[0], Is.EqualTo("IObserver")); + Assert.That(values[1], Is.EqualTo("IObserver")); + Assert.That(values[2], Is.EqualTo("Foo.BogusVisitor")); + + foreach (var element in cm.PropertyIterator) + { + var ma = element.MetaAttributes; + Assert.That(ma, Is.Not.Null); + Assert.That(element.GetMetaAttribute("global"), Is.Not.Null,"inherited attribute missing for prop {0}",element.Name); + MetaAttribute metaAttribute2 = element.GetMetaAttribute("implements"); + Assert.That(metaAttribute2, Is.Not.Null); + Assert.That(element.GetMetaAttribute("globalnoinherit"), Is.Null); + } + + Property prop = cm.GetProperty("Component"); + var map = prop.MetaAttributes; + Assert.That(map, Is.Not.Null); + Assert.That(prop.GetMetaAttribute("global"), Is.Not.Null); + Assert.That(prop.GetMetaAttribute("componentonly"), Is.Not.Null); + Assert.That(prop.GetMetaAttribute("allcomponent"), Is.Not.Null); + Assert.That(prop.GetMetaAttribute("globalnoinherit"), Is.Null); + + MetaAttribute compimplements = prop.GetMetaAttribute("implements"); + Assert.That(compimplements, Is.Not.Null); + Assert.That(compimplements.Value, Is.EqualTo("AnotherInterface")); + + Property xp = ((Component)prop.Value).GetProperty("X"); + MetaAttribute propximplements = xp.GetMetaAttribute("implements"); + Assert.That(propximplements, Is.Not.Null); + Assert.That(propximplements.Value, Is.EqualTo("AnotherInterface")); } [Test] Modified: trunk/nhibernate/src/NHibernate.Test/MappingTest/Wicked.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/MappingTest/Wicked.cs 2009-05-12 04:53:16 UTC (rev 4282) +++ trunk/nhibernate/src/NHibernate.Test/MappingTest/Wicked.cs 2009-05-12 15:29:32 UTC (rev 4283) @@ -7,6 +7,7 @@ { public int Id { get; set; } public int VersionProp { get; set; } + public MonetaryAmount Component { get; set; } public ISet SortedEmployee { get; set; } public IList AnotherSet { get; set; } } Modified: trunk/nhibernate/src/NHibernate.Test/MappingTest/Wicked.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/MappingTest/Wicked.hbm.xml 2009-05-12 04:53:16 UTC (rev 4282) +++ trunk/nhibernate/src/NHibernate.Test/MappingTest/Wicked.hbm.xml 2009-05-12 15:29:32 UTC (rev 4283) @@ -20,7 +20,7 @@ <generator class="assigned"/> </id> <version name="VersionProp"/> - <component name="component" class="MonetaryAmount"> + <component name="Component" class="MonetaryAmount"> <meta attribute="componentonly" inherit="true"/> <meta attribute="implements">AnotherInterface</meta> <meta attribute="allcomponent"/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |