|
From: <fab...@us...> - 2009-05-13 05:58:45
|
Revision: 4286
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4286&view=rev
Author: fabiomaulo
Date: 2009-05-13 05:58:35 +0000 (Wed, 13 May 2009)
Log Message:
-----------
Fixing ignored mappings nodes (fixed)
Modified Paths:
--------------
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/SubclassBinder.cs
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/UnionSubclassBinder.cs
trunk/nhibernate/src/NHibernate/Mapping/Component.cs
trunk/nhibernate/src/NHibernate/Mapping/Property.cs
trunk/nhibernate/src/NHibernate.Test/MappingTest/NonReflectiveBinderFixture.cs
Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs 2009-05-13 05:44:30 UTC (rev 4285)
+++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs 2009-05-13 05:58:35 UTC (rev 4286)
@@ -96,13 +96,13 @@
model.AddJoin(join);
}
else if ("subclass".Equals(name))
- new SubclassBinder(this).HandleSubclass(model, subnode);
+ new SubclassBinder(this).HandleSubclass(model, subnode, inheritedMetas);
else if ("joined-subclass".Equals(name))
- new JoinedSubclassBinder(this).HandleJoinedSubclass(model, subnode);
+ new JoinedSubclassBinder(this).HandleJoinedSubclass(model, subnode, inheritedMetas);
else if ("union-subclass".Equals(name))
- new UnionSubclassBinder(this).HandleUnionSubclass(model, subnode);
+ new UnionSubclassBinder(this).HandleUnionSubclass(model, subnode, inheritedMetas);
else if ("filter".Equals(name))
ParseFilter(subnode, model);
Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/JoinedSubclassBinder.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/JoinedSubclassBinder.cs 2009-05-13 05:44:30 UTC (rev 4285)
+++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/JoinedSubclassBinder.cs 2009-05-13 05:58:35 UTC (rev 4286)
@@ -2,6 +2,7 @@
using NHibernate.Mapping;
using NHibernate.Persister.Entity;
+using System.Collections.Generic;
namespace NHibernate.Cfg.XmlHbmBinding
{
@@ -17,18 +18,18 @@
{
}
- public void Bind(XmlNode node)
+ public void Bind(XmlNode node, IDictionary<string, MetaAttribute> inheritedMetas)
{
PersistentClass superModel = GetSuperclass(node);
- HandleJoinedSubclass(superModel, node);
+ HandleJoinedSubclass(superModel, node, inheritedMetas);
}
- public void HandleJoinedSubclass(PersistentClass model, XmlNode subnode)
+ public void HandleJoinedSubclass(PersistentClass model, XmlNode subnode, IDictionary<string, MetaAttribute> inheritedMetas)
{
JoinedSubclass subclass = new JoinedSubclass(model);
- BindClass(subnode, null, subclass, EmptyMeta);
-
+ BindClass(subnode, null, subclass, inheritedMetas);
+ inheritedMetas = GetMetas(subnode.SelectNodes(HbmConstants.nsMeta, namespaceManager), inheritedMetas, true); // get meta's from <joined-subclass>
// joined subclass
if (subclass.EntityPersisterClass == null)
subclass.RootClazz.EntityPersisterClass = typeof(JoinedSubclassEntityPersister);
@@ -70,7 +71,7 @@
mytable.AddCheckConstraint(chNode.Value);
// properties
- PropertiesFromXML(subnode, subclass, EmptyMeta);
+ PropertiesFromXML(subnode, subclass, inheritedMetas);
model.AddSubclass(subclass);
mappings.AddClass(subclass);
Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/MappingRootBinder.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/MappingRootBinder.cs 2009-05-13 05:44:30 UTC (rev 4285)
+++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/MappingRootBinder.cs 2009-05-13 05:58:35 UTC (rev 4286)
@@ -33,9 +33,9 @@
AddTypeDefs(mappingSchema);
AddRootClasses(node, inheritedMetas);
- AddSubclasses(node);
- AddJoinedSubclasses(node);
- AddUnionSubclasses(node);
+ AddSubclasses(node, inheritedMetas);
+ AddJoinedSubclasses(node, inheritedMetas);
+ AddUnionSubclasses(node, inheritedMetas);
AddQueries(mappingSchema);
AddSqlQueries(mappingSchema);
@@ -73,28 +73,28 @@
binder.Bind(node, Deserialize<HbmClass>(node), inheritedMetas);
}
- private void AddUnionSubclasses(XmlNode parentNode)
+ private void AddUnionSubclasses(XmlNode parentNode, IDictionary<string, MetaAttribute> inheritedMetas)
{
UnionSubclassBinder binder = new UnionSubclassBinder(this, namespaceManager, dialect);
foreach (XmlNode node in parentNode.SelectNodes(HbmConstants.nsUnionSubclass, namespaceManager))
- binder.Bind(node);
+ binder.Bind(node, inheritedMetas);
}
- private void AddJoinedSubclasses(XmlNode parentNode)
+ private void AddJoinedSubclasses(XmlNode parentNode, IDictionary<string, MetaAttribute> inheritedMetas)
{
JoinedSubclassBinder binder = new JoinedSubclassBinder(this, namespaceManager, dialect);
foreach (XmlNode node in parentNode.SelectNodes(HbmConstants.nsJoinedSubclass, namespaceManager))
- binder.Bind(node);
+ binder.Bind(node, inheritedMetas);
}
- private void AddSubclasses(XmlNode parentNode)
+ private void AddSubclasses(XmlNode parentNode, IDictionary<string, MetaAttribute> inheritedMetas)
{
SubclassBinder binder = new SubclassBinder(this, namespaceManager, dialect);
foreach (XmlNode node in parentNode.SelectNodes(HbmConstants.nsSubclass, namespaceManager))
- binder.Bind(node);
+ binder.Bind(node, inheritedMetas);
}
private void AddQueries(HbmMapping mappingSchema)
Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/SubclassBinder.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/SubclassBinder.cs 2009-05-13 05:44:30 UTC (rev 4285)
+++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/SubclassBinder.cs 2009-05-13 05:58:35 UTC (rev 4286)
@@ -1,3 +1,4 @@
+using System.Collections.Generic;
using System.Xml;
using NHibernate.Mapping;
@@ -17,25 +18,27 @@
{
}
- public void Bind(XmlNode node)
+ public void Bind(XmlNode node, IDictionary<string, MetaAttribute> inheritedMetas)
{
PersistentClass superModel = GetSuperclass(node);
- HandleSubclass(superModel, node);
+ HandleSubclass(superModel, node, inheritedMetas);
}
- public void HandleSubclass(PersistentClass model, XmlNode subnode)
+ public void HandleSubclass(PersistentClass model, XmlNode subnode, IDictionary<string, MetaAttribute> inheritedMetas)
{
Subclass subclass = new SingleTableSubclass(model);
- BindClass(subnode, null, subclass, EmptyMeta);
+ BindClass(subnode, null, subclass, inheritedMetas);
+ inheritedMetas = GetMetas(subnode.SelectNodes(HbmConstants.nsMeta, namespaceManager), inheritedMetas, true); // get meta's from <subclass>
+
if (subclass.EntityPersisterClass == null)
subclass.RootClazz.EntityPersisterClass = typeof(SingleTableEntityPersister);
log.InfoFormat("Mapping subclass: {0} -> {1}", subclass.EntityName, subclass.Table.Name);
// properties
- PropertiesFromXML(subnode, subclass, EmptyMeta);
+ PropertiesFromXML(subnode, subclass, inheritedMetas);
model.AddSubclass(subclass);
mappings.AddClass(subclass);
Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/UnionSubclassBinder.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/UnionSubclassBinder.cs 2009-05-13 05:44:30 UTC (rev 4285)
+++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/UnionSubclassBinder.cs 2009-05-13 05:58:35 UTC (rev 4286)
@@ -1,3 +1,4 @@
+using System.Collections.Generic;
using System.Xml;
using NHibernate.Mapping;
using NHibernate.Persister.Entity;
@@ -16,17 +17,18 @@
{
}
- public void Bind(XmlNode node)
+ public void Bind(XmlNode node, IDictionary<string, MetaAttribute> inheritedMetas)
{
PersistentClass superModel = GetSuperclass(node);
- HandleUnionSubclass(superModel, node);
+ HandleUnionSubclass(superModel, node, inheritedMetas);
}
- public void HandleUnionSubclass(PersistentClass model, XmlNode subnode)
+ public void HandleUnionSubclass(PersistentClass model, XmlNode subnode, IDictionary<string, MetaAttribute> inheritedMetas)
{
- UnionSubclass unionSubclass = new UnionSubclass(model);
+ var unionSubclass = new UnionSubclass(model);
- BindClass(subnode, null, unionSubclass, EmptyMeta);
+ BindClass(subnode, null, unionSubclass, inheritedMetas);
+ inheritedMetas = GetMetas(subnode.SelectNodes(HbmConstants.nsMeta, namespaceManager), inheritedMetas, true); // get meta's from <union-subclass>
// union subclass
if (unionSubclass.EntityPersisterClass == null)
@@ -47,7 +49,7 @@
log.InfoFormat("Mapping union-subclass: {0} -> {1}", unionSubclass.EntityName, unionSubclass.Table.Name);
// properties
- PropertiesFromXML(subnode, unionSubclass, EmptyMeta);
+ PropertiesFromXML(subnode, unionSubclass, inheritedMetas);
model.AddSubclass(unionSubclass);
mappings.AddClass(unionSubclass);
Modified: trunk/nhibernate/src/NHibernate/Mapping/Component.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Mapping/Component.cs 2009-05-13 05:44:30 UTC (rev 4285)
+++ trunk/nhibernate/src/NHibernate/Mapping/Component.cs 2009-05-13 05:58:35 UTC (rev 4286)
@@ -11,7 +11,7 @@
/// etc.
/// </summary>
[Serializable]
- public class Component : SimpleValue
+ public class Component : SimpleValue, IMetaAttributable
{
private readonly List<Property> properties = new List<Property>();
private System.Type componentClass;
@@ -320,5 +320,16 @@
}
public IDictionary<string, MetaAttribute> MetaAttributes { get; set; }
+
+ public MetaAttribute GetMetaAttribute(string attributeName)
+ {
+ if (MetaAttributes == null)
+ {
+ return null;
+ }
+ MetaAttribute 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-13 05:44:30 UTC (rev 4285)
+++ trunk/nhibernate/src/NHibernate/Mapping/Property.cs 2009-05-13 05:58:35 UTC (rev 4286)
@@ -206,6 +206,10 @@
public MetaAttribute GetMetaAttribute(string attributeName)
{
+ if(metaAttributes == null)
+ {
+ return null;
+ }
MetaAttribute result;
metaAttributes.TryGetValue(attributeName, out result);
return result;
Modified: trunk/nhibernate/src/NHibernate.Test/MappingTest/NonReflectiveBinderFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/MappingTest/NonReflectiveBinderFixture.cs 2009-05-13 05:44:30 UTC (rev 4285)
+++ trunk/nhibernate/src/NHibernate.Test/MappingTest/NonReflectiveBinderFixture.cs 2009-05-13 05:58:35 UTC (rev 4286)
@@ -76,6 +76,86 @@
}
[Test]
+ public void NonMutatedInheritance()
+ {
+ PersistentClass cm = cfg.GetClassMapping("NHibernate.Test.MappingTest.Wicked");
+ MetaAttribute metaAttribute = cm.GetMetaAttribute("globalmutated");
+
+ Assert.That(metaAttribute, Is.Not.Null);
+ /*assertEquals( metaAttribute.getValues().size(), 2 );
+ assertEquals( "top level", metaAttribute.getValues().get(0) );*/
+ Assert.That(metaAttribute.Value, Is.EqualTo("wicked level"));
+
+ Property property = cm.GetProperty("Component");
+ MetaAttribute propertyAttribute = property.GetMetaAttribute("globalmutated");
+
+ Assert.That(propertyAttribute, Is.Not.Null);
+ /*assertEquals( propertyAttribute.getValues().size(), 3 );
+ assertEquals( "top level", propertyAttribute.getValues().get(0) );
+ assertEquals( "wicked level", propertyAttribute.getValues().get(1) );*/
+ Assert.That(propertyAttribute.Value, Is.EqualTo("monetaryamount level"));
+
+ var component = (Component)property.Value;
+ property = component.GetProperty("X");
+ propertyAttribute = property.GetMetaAttribute("globalmutated");
+
+ Assert.That(propertyAttribute, Is.Not.Null);
+ /*assertEquals( propertyAttribute.getValues().size(), 4 );
+ assertEquals( "top level", propertyAttribute.getValues().get(0) );
+ assertEquals( "wicked level", propertyAttribute.getValues().get(1) );
+ assertEquals( "monetaryamount level", propertyAttribute.getValues().get(2) );*/
+ Assert.That(propertyAttribute.Value, Is.EqualTo("monetaryamount x level"));
+
+ property = cm.GetProperty("SortedEmployee");
+ propertyAttribute = property.GetMetaAttribute("globalmutated");
+
+ Assert.That(propertyAttribute, Is.Not.Null);
+ /*assertEquals( propertyAttribute.getValues().size(), 3 );
+ assertEquals( "top level", propertyAttribute.getValues().get(0) );
+ assertEquals( "wicked level", propertyAttribute.getValues().get(1) );*/
+ Assert.That(propertyAttribute.Value, Is.EqualTo("sortedemployee level"));
+
+ property = cm.GetProperty("AnotherSet");
+ propertyAttribute = property.GetMetaAttribute("globalmutated");
+
+ Assert.That(propertyAttribute, Is.Not.Null);
+ /*assertEquals( propertyAttribute.getValues().size(), 2 );
+ assertEquals( "top level", propertyAttribute.getValues().get(0) );*/
+ Assert.That(propertyAttribute.Value, Is.EqualTo("wicked level"));
+
+ var bag = (Bag)property.Value;
+ component = (Component)bag.Element;
+
+ Assert.That(component.MetaAttributes.Count, Is.EqualTo(4));
+
+ metaAttribute = component.GetMetaAttribute("globalmutated");
+ /*assertEquals( metaAttribute.getValues().size(), 3 );
+ assertEquals( "top level", metaAttribute.getValues().get(0) );
+ assertEquals( "wicked level", metaAttribute.getValues().get(1) );*/
+ Assert.That(metaAttribute.Value, Is.EqualTo("monetaryamount anotherSet composite level"));
+
+ property = component.GetProperty("Emp");
+ propertyAttribute = property.GetMetaAttribute("globalmutated");
+
+ Assert.That(propertyAttribute, Is.Not.Null);
+ /*assertEquals( propertyAttribute.getValues().size(), 4 );
+ assertEquals( "top level", propertyAttribute.getValues().get(0) );
+ assertEquals( "wicked level", propertyAttribute.getValues().get(1) );
+ assertEquals( "monetaryamount anotherSet composite level", propertyAttribute.getValues().get(2) );*/
+ Assert.That(propertyAttribute.Value, Is.EqualTo("monetaryamount anotherSet composite property emp level"));
+
+ property = component.GetProperty("Empinone");
+ propertyAttribute = property.GetMetaAttribute("globalmutated");
+
+ Assert.That(propertyAttribute, Is.Not.Null);
+ /*assertEquals( propertyAttribute.getValues().size(), 4 );
+ assertEquals( "top level", propertyAttribute.getValues().get(0) );
+ assertEquals( "wicked level", propertyAttribute.getValues().get(1) );
+ assertEquals( "monetaryamount anotherSet composite level", propertyAttribute.getValues().get(2) );*/
+ Assert.That(propertyAttribute.Value, Is.EqualTo("monetaryamount anotherSet composite property empinone level"));
+ }
+
+ [Test]
public void Comparator()
{
PersistentClass cm = cfg.GetClassMapping("NHibernate.Test.MappingTest.Wicked");
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|