Additionally I'm now getting the following error:

PersistenceTests.Can_Map_Orders_To_Database : Failed
System.Xml.Schema.XmlSchemaValidationException:

The element 'class' in namespace 'urn:nhibernate-mapping-2.2' has
invalid child element 'set' in

namespace 'urn:nhibernate-mapping-2.2'. List of possible elements
expected: 'id, composite-id' in

namespace 'urn:nhibernate-mapping-2.2'.
-- Exception doesn't have a stack trace --
NHibernate.MappingException: (XmlDocument)(5,6): XML validation error:
The element 'class' in

namespace 'urn:nhibernate-mapping-2.2' has invalid child element 'set'
in namespace

'urn:nhibernate-mapping-2.2'. List of possible elements expected: 'id,
composite-id' in namespace

'urn:nhibernate-mapping-2.2'.
at NHibernate.Cfg.Configuration.LogAndThrow(Exception exception)
at NHibernate.Cfg.Configuration.ValidationHandler(Object o,
ValidationEventArgs args)
at System.Xml.Schema.XmlSchemaValidator.SendValidationEvent
(ValidationEventHandler eventHandler,

Object sender, XmlSchemaValidationException e, XmlSeverityType
severity)
at System.Xml.Schema.XmlSchemaValidator.ElementValidationError
(XmlQualifiedName name, ValidationState

context, ValidationEventHandler eventHandler, Object sender, String
sourceUri, Int32 lineNo, Int32

linePos, Boolean getParticles)
at System.Xml.Schema.XmlSchemaValidator.ValidateElementContext
(XmlQualifiedName elementName, ref

Boolean invalidElementInContext)
at System.Xml.Schema.XmlSchemaValidator.ValidateElement(String
localName, String namespaceUri,

XmlSchemaInfo schemaInfo, String xsiType, String xsiNil, String
xsiSchemaLocation, String

xsiNoNamespaceSchemaLocation)
at System.Xml.XsdValidatingReader.ProcessElementEvent()
at System.Xml.XsdValidatingReader.ProcessReaderEvent()
at System.Xml.XsdValidatingReader.Read()
at System.Xml.XmlLoader.LoadNode(Boolean skipOverWhitespace)
at System.Xml.XmlLoader.LoadDocSequence(XmlDocument parentDoc)
at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader,
Boolean preserveWhitespace)
at System.Xml.XmlDocument.Load(XmlReader reader)
at NHibernate.Cfg.Configuration.LoadMappingDocument(XmlReader
hbmReader, String name)
at NHibernate.Cfg.Configuration.AddXmlReader(XmlReader hbmReader,
String name)
at NHibernate.Cfg.Configuration.AddInputStream(Stream xmlInputStream,
String name)
at NHibernate.Cfg.Configuration.AddDocument(XmlDocument doc, String
name)
at NHibernate.Cfg.Configuration.AddDocument(XmlDocument doc)
at FluentNHibernate.MappingVisitor.AddMappingDocument(XmlDocument
document, Type type) in c:\Code

Samples\NHibernate\Fluent Nhibernate\src\FluentNHibernate
\MappingVisitor.cs: line 34
at FluentNHibernate.Mapping.ClassMap`1.ApplyMappings(IMappingVisitor
visitor) in c:\Code

Samples\NHibernate\Fluent Nhibernate\src\FluentNHibernate\Mapping
\ClassMap.cs: line 184
System.ApplicationException: Error while trying to build the Mapping
Document for

'Core.Domain.Entities.Order+Item'
at FluentNHibernate.Mapping.ClassMap`1.ApplyMappings(IMappingVisitor
visitor) in c:\Code

Samples\NHibernate\Fluent Nhibernate\src\FluentNHibernate\Mapping
\ClassMap.cs: line 200
at FluentNHibernate.PersistenceModel.<>c__DisplayClass1.<Configure>b__0
(IMapping mapping) in c:\Code

Samples\NHibernate\Fluent Nhibernate\src\FluentNHibernate
\PersistenceModel.cs: line 91
at System.Collections.Generic.List`1.ForEach(Action`1 action)
at FluentNHibernate.PersistenceModel.Configure(Configuration
configuration) in c:\Code

Samples\NHibernate\Fluent Nhibernate\src\FluentNHibernate
\PersistenceModel.cs: line 91
at FluentNHibernate.AutoMap.AutoPersistenceModel.Configure
(Configuration configuration) in c:\Code

Samples\NHibernate\Fluent Nhibernate\src\FluentNHibernate\AutoMap
\AutoPersistenceModel.cs: line 115
at FluentNHibernate.Cfg.AutoMappingsContainer.Apply(Configuration cfg)
in c:\Code

Samples\NHibernate\Fluent Nhibernate\src\FluentNHibernate\Cfg
\AutoMappingsContainer.cs: line 70
at FluentNHibernate.Cfg.MappingConfiguration.Apply(Configuration cfg)
in c:\Code

Samples\NHibernate\Fluent Nhibernate\src\FluentNHibernate\Cfg
\MappingConfiguration.cs: line 51
at FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory() in
FluentConfiguration.cs: line 93
FluentNHibernate.Cfg.FluentConfigurationException: An invalid or
incomplete configuration was used

while creating a SessionFactory. Check PotentialReasons collection,
and InnerException for more

detail.


at FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory() in
FluentConfiguration.cs: line 102
at Core.Infrastructure.Data.NHibernate.Tests.PersistenceTests.SetUp()
in PersistenceTests.cs: line 22

This is the mapping file produced from the APM:

<?xml version="1.0" encoding="utf-8"?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" default-
lazy="true" assembly="Core.Domain" namespace="Core.Domain.Entities"
schema="Orders">
  <class name="Item" table="OrderItem" xmlns="urn:nhibernate-
mapping-2.2">
    <cache usage="read-write" />
    <set name="Parts" cascade="save-update">
      <key column="ItemID" />
      <one-to-many class="Core.Domain.Entities.Order+Item+Part,
Core.Domain, Version=0.1.3336.32427, Culture=neutral,
PublicKeyToken=94dc7dc697cfcfc0" />
    </set>
    <many-to-one property-ref="Items" name="Order" column="OrderId" />
  </class>
</hibernate-mapping>

For some reason it only contains the parts I'd overridden in my
mapping override for Order.Item. I'm guessing the AutoMapper's
mapEverythingInClass either was not called or it was not merged with
the overrides in the IMappingOverride. Also, the class name is just
"Item". Could it be that the validation was trying to find a class
named Item and couldn't find it and hence it wasn't mapped/merged?

Here's the override:
    [CLSCompliant(false)]
    public class OrderItemAutoMappingOverride :
IAutoMappingOverride<Order.Item>
    {

        #region IAutoMappingOverride<Item> Members

        public void Override
(FluentNHibernate.AutoMap.AutoMap<Order.Item> mapping)
        {
            mapping.HasMany(item => item.Parts)
                .AsSet()
                .Cascade.All();
            mapping.References(i => i.Order)
                .PropertyRef(o => o.Items);
            mapping.SchemaIs("Orders");
            //mapping.WithTable("OrderItem");
        }

        #endregion
    }

I've seen similar results with all my nested classes. The AutoMapper
is either not discovering their properties or the discovered
properties are not getting merged with my mapping overrides.


On Feb 18, 11:05 am, Jimit <jimitndi...@gmail.com> wrote:
> Glad to help.
> It seems not to have solved my problem though. Amappingfile for
> DomainObject is still being generated. I think because
> ForTypesThatDeriveFrom<DomainObject> (or IMappingOverride.Override)
> creates an AutoMap<DomainObject> for DomainObject (which is meant to
> be used just for merging with AutoMaps of derived types since
> DomainObject is a base class) it still bypasses the logic that would
> exclude it. This means that base classes make it into the 
> finalmappingregardless of their exclusion by Conventions.IsBaseClass. I
> think we might need to do a final filter after all the merges have
> been done to exclude base class AutoMaps that were created by
> ForTypesThatDeriveFrom or via an IMappingOverride. Alternatively we
> could add a parameter to AutoMapper.MergeMap called isBaseClass (bool)
> which we could use to determine if mapEverythingInClass() should be
> called (i.e do we just want to merge with mappings for derived types
> or do we want to map the class itself as well).
>
> On Feb 17, 10:59 pm, James Gregory <jagregory....@gmail.com> wrote:
>
> > Thanks for the patch, I will review it tomorrow.
>
> > On Tue, Feb 17, 2009 at 6:58 PM, Jimit <jimitndi...@gmail.com> wrote:
>
> > > I've created a patch adding support formappingentities in multiple
> > > assemblies. It basically follows the logic I suggested in the posts
> > > above. I've added a test verifying it works and as well as updated 3
> > > tests that were failing as a result (I think) of a recent change in
> > > the mappings pushing column declarations in the xml from attributes to
> > > elements. I just updated the XPATH query to point to the "column"
> > > element and set the HasAttribute to look for the "name" attribute for
> > > all three tests. They are (in the AutoPersistenceModelTests class):
> > > MapsPropertyWithPropertyConvention,
> > > ComponentColumnConventionReceivesProperty and
> > > ComponentPropertiesAssumeComponentColumnPrefix. You might want to
> > > confirm that that is the expected behaviour.
>
> > > In order to create the test formappingentities from multiple
> > > assemblies I added a reference to Examples.FirstProject to the test
> > > project.
>
> > > Here's the patch. I apologize in advance if this isn't the accepted
> > > way to submit patches. Just let me know how it's normally done and
> > > I'll do so henceforth.:
>
> > > Index: src/FluentNHibernate.Testing/AutoMap/
> > > AutoPersistenceModelTests.cs
> > > ===================================================================
> > > --- src/FluentNHibernate.Testing/AutoMap/AutoPersistenceModelTests.cs
> > > (revision 0)
> > > +++ src/FluentNHibernate.Testing/AutoMap/AutoPersistenceModelTests.cs
> > > (revision 0)
> > > @@ -0,0 +1,477 @@
> > > +using System;
> > > +using System.Diagnostics;
> > > +using FluentNHibernate.AutoMap;
> > > +using FluentNHibernate.AutoMap.TestFixtures.ComponentTypes;
> > > +using FluentNHibernate.AutoMap.TestFixtures.CustomTypes;
> > > +using NUnit.Framework;
> > > +using SuperTypes = FluentNHibernate.AutoMap.TestFixtures.SuperTypes;
> > > +using FluentNHibernate.AutoMap.TestFixtures;
> > > +
> > > +namespace FluentNHibernate.Testing.AutoMap
> > > +{
> > > +    using Examples.FirstProject.Entities;
> > > +    using Fixtures.EntitiesInMultipleAssemblies;
> > > +
> > > +    [TestFixture]
> > > +    public class AutoPersistenceModelTests : BaseAutoPersistenceTests
> > > +    {
> > > +        [Test]
> > > +        public void MapsPropertyWithPropertyConvention()
> > > +        {
> > > +            var autoMapper = AutoPersistenceModel
> > > +                .MapEntitiesFromAssemblyOf<ExampleCustomColumn>()
> > > +                .Where(t => t.Namespace ==
> > > "FluentNHibernate.AutoMap.TestFixtures")
> > > +                .WithConvention(convention =>
> > > +                {
> > > +                    convention.AddPropertyConvention(new
> > > XXAppenderPropertyConvention());
> > > +                });
> > > +
> > > +            autoMapper.Configure(cfg);
> > > +
> > > +            new AutoMappingTester<ExampleClass>(autoMapper)
> > > +                .Element("class/proper...@name='LineOne']/
> > > column").HasAttribute("name", "LineOneXX");
> > > +        }
> > > +
> > > +        [Test]
> > > +        public void TestAutoMapsIds()
> > > +        {
> > > +            var autoMapper = AutoPersistenceModel
> > > +                .MapEntitiesFromAssemblyOf<ExampleCustomColumn>()
> > > +                .Where(t => t.Namespace ==
> > > "FluentNHibernate.AutoMap.TestFixtures");
> > > +
> > > +            autoMapper.Configure(cfg);
> > > +
> > > +            new AutoMappingTester<ExampleClass>(autoMapper)
> > > +                .Element("class/id").Exists();
> > > +        }
> > > +
> > > +        [Test]
> > > +        public void TestAutoMapsProperties()
> > > +        {
> > > +            var autoMapper = AutoPersistenceModel
> > > +                .MapEntitiesFromAssemblyOf<ExampleClass>()
> > > +                .Where(t => t.Namespace ==
> > > "FluentNHibernate.AutoMap.TestFixtures");
> > > +
> > > +            autoMapper.Configure(cfg);
> > > +
> > > +            new AutoMappingTester<ExampleClass>(autoMapper)
> > > +                .Element("//property").HasAttribute("name",
> > > "ExampleClassId");
> > > +        }
> > > +
> > > +        [Test]
> > > +        public void TestAutoMapIgnoresProperties()
> > > +        {
> > > +            var autoMapper = AutoPersistenceModel
> > > +                .MapEntitiesFromAssemblyOf<ExampleClass>()
> > > +                .Where(t => t.Namespace ==
> > > "FluentNHibernate.AutoMap.TestFixtures")
> > > +                .ForTypesThatDeriveFrom<ExampleCustomColumn>(c =>
> > > c.IgnoreProperty(p => p.ExampleCustomColumnId));
> > > +
> > > +            autoMapper.Configure(cfg);
> > > +
> > > +            new AutoMappingTester<ExampleCustomColumn>(autoMapper)
> > > +                .Element("//property").DoesntExist();
> > > +        }
> > > +
> > > +        [Test]
> > > +        public void TestAutoMapManyToOne()
> > > +        {
> > > +            var autoMapper = AutoPersistenceModel
> > > +                .MapEntitiesFromAssemblyOf<ExampleClass>()
> > > +                .Where(t => t.Namespace ==
> > > "FluentNHibernate.AutoMap.TestFixtures");
> > > +
> > > +            autoMapper.Configure(cfg);
> > > +
> > > +            new AutoMappingTester<ExampleClass>(autoMapper)
> > > +                .Element("//many-to-one").HasAttribute("name",
> > > "Parent");
> > > +        }
> > > +
> > > +        [Test]
> > > +        public void TestAutoMapOneToMany()
> > > +        {
> > > +            var autoMapper = AutoPersistenceModel
> > > +                .MapEntitiesFromAssemblyOf<ExampleParentClass>()
> > > +                .Where(t => t.Namespace ==
> > > "FluentNHibernate.AutoMap.TestFixtures");
> > > +
> > > +            autoMapper.Configure(cfg);
> > > +
> > > +            new AutoMappingTester<ExampleParentClass>(autoMapper)
> > > +                .Element("//bag")
> > > +                .HasAttribute("name", "Examples");
> > > +        }
> > > +
> > > +        [Test]
> > > +        public void TestAutoMapPropertyMergeOverridesId()
> > > +        {
> > > +            var autoMapper = AutoPersistenceModel
> > > +                .MapEntitiesFromAssemblyOf<ExampleClass>()
> > > +                .Where(t => t.Namespace ==
> > > "FluentNHibernate.AutoMap.TestFixtures")
> > > +                .ForTypesThatDeriveFrom<ExampleClass>(map => map.Id(c
> > > => c.Id, "Column"));
> > > +
> > > +            autoMapper.Configure(cfg);
> > > +
> > > +            new AutoMappingTester<ExampleClass>(autoMapper)
> > > +                .Element("class/id")
> > > +                .HasAttribute("name", "Id")
> > > +                .HasAttribute("column", "Column");
> > > +        }
> > > +
> > > +        [Test]
> > > +        public void TestAutoMapPropertySetPrimaryKeyConvention()
> > > +        {
> > > +            var autoMapper = AutoPersistenceModel
> > > +                .MapEntitiesFromAssemblyOf<ExampleClass>()
> > > +                .Where(t => t.Namespace ==
> > > "FluentNHibernate.AutoMap.TestFixtures")
> > > +                .WithConvention(c=> c.GetPrimaryKeyName = p=> p.Name
> > > + "Id");
> > > +
> > > +            autoMapper.Configure(cfg);
> > > +
> > > +            new AutoMappingTester<ExampleClass>(autoMapper)
> > > +                .Element("class/id")
> > > +                .HasAttribute("name", "Id")
> > > +                .HasAttribute("column", "IdId");
> > > +        }
> > > +
> > > +        [Test]
> > > +        public void TestAutoMapIdUsesConvention()
> > > +        {
> > > +            var autoMapper = AutoPersistenceModel
> > > +                .MapEntitiesFromAssemblyOf<PrivateIdSetterClass>()
> > > +                .Where(t => t.Namespace ==
> > > "FluentNHibernate.AutoMap.TestFixtures")
> > > +                .WithConvention(convention =>
> > > +                    convention.IdConvention = id =>
> > > id.Access.AsLowerCaseField());
> > > +
> > > +            autoMapper.Configure(cfg);
> > > +
> > > +            new AutoMappingTester<PrivateIdSetterClass>(autoMapper)
> > > +                .Element("class/id")
> > > +                .HasAttribute("access", "field.lowercase");
> > > +        }
> > > +
> > > +        [Test]
> > > +        public void TestAutoMapPropertySetManyToOneKeyConvention()
> > > +        {
> > > +            var autoMapper = AutoPersistenceModel
> > > +              
>
> ...
>
> read more »
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" group.
To post to this group, send email to fluent-nhibernate@googlegroups.com
To unsubscribe from this group, send email to 
fluent-nhibernate+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/fluent-nhibernate?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to