@Neo:
This seems related to the a bug I've discovered where the AutoMapper
generates joinedsubclass mappings even when you've explicitly defined
subclass mappings with a discriminator in your mapping override. You
could refer to this thread: 
http://groups.google.com/group/fluent-nhibernate/browse_thread/thread/15fdb057ec89078e

On Feb 18, 8:44 pm, Neo <digaomat...@gmail.com> wrote:
> Hello guys.
>
> I'm having a problem to map inheritance using the Override method in
> AutoMapping.
>
> This is the error I'm having on the unit test:
>
> System.ApplicationException : Error while trying to build the Mapping
> Document for 'DWSpace.Core.Person'
>   ----> NHibernate.MappingException : (XmlDocument)(54,6): XML
> validation error: The element 'class' in namespace 'urn:nhibernate-
> mapping-2.2' has invalid child element 'subclass' in namespace
> 'urn:nhibernate-mapping-2.2'. List of possible elements expected:
> 'joined-subclass, loader, sql-insert, sql-update, sql-delete, filter'
> in namespace 'urn:nhibernate-mapping-2.2'.
>   ----> System.Xml.Schema.XmlSchemaValidationException : The element
> 'class' in namespace 'urn:nhibernate-mapping-2.2' has invalid child
> element 'subclass' in namespace 'urn:nhibernate-mapping-2.2'. List of
> possible elements expected: 'joined-subclass, loader, sql-insert, sql-
> update, sql-delete, filter' in namespace 'urn:nhibernate-mapping-2.2'.
> TearDown : System.Reflection.TargetInvocationException : Exception has
> been thrown by the target of an invocation.
>   ----> System.NullReferenceException : Object reference not set to an
> instance of an object.
>
> Here's my mapping:
>
> public class PersonMap : IAutoMappingOverride<Person>
>     {
>         public void Override(AutoMap<Person> mapping)
>         {
>             mapping.SetHibernateMappingAttribute("default-lazy",
> "false");
>             mapping.WithTable("Person");
>
>             mapping.Id(x => x.ID, "Id")
>             .WithUnsavedValue(0)
>             .GeneratedBy.Sequence("HIBERNATE_SEQUENCE");
>
>             mapping.Map(x => x.FirstName, "FirstName").Not.Nullable();
>             mapping.Map(x => x.LastName, "LastName");
>             mapping.Map(x => x.CreatedDate);
>
>             mapping.HasMany<Contact>(person => person.Contacts)
>                     .AsSet()
>                     .WithTableName("Contact")
>                     .WithKeyColumn("Id")
>                     .Component(ct =>
>                     {
>                         ct.Map(c => c.Type, "ContactType").Not.Nullable
> ().CustomTypeIs(typeof(ContactType));
>                         ct.Map(c => c.Description,
> "Description").Not.Nullable();
>                     });
>
>             mapping.Component<LoginInfo>(x => x.Login, lg =>
>                                                {
>                                                    lg.Map(x =>
> x.UserName)
>                                                      .TheColumnNameIs
> ("LoginName");
>                                                    lg.Map(x =>
> x.Password)
>                                                      .TheColumnNameIs
> ("LoginPassword");
>                                                    lg.Map(x => x.Salt)
>                                                      .TheColumnNameIs
> ("LoginSalt");
>                                                });
>
>             var discrimination = mapping.DiscriminateSubClassesOnColumn
> ("PersonType", (Int16)PersonType.Person);
>
>             discrimination.SubClass<Employee>((short)
> PersonType.Employee, m =>
>
> {
>
> m.HasMany<EmployeeTimeEntry>(x => x.WorkTimeSet)
>                                                                               
>      .WithKeyColumn
> ("Emp_Id")
>                                                                               
>      .Cascade.All
> ()
>                                                                               
>      .AsBag
> ();
>
> m.HasManyToMany<WorkPeriod>(
>
> x => x.WorkPeriodSet)
>                                                                               
>      .WithTableName
> ("EmployeeWorkPeriod")
>                                                                               
>      .WithParentKeyColumn
> ("Emp_Id")
>                                                                               
>      .WithChildKeyColumn
> ("Id")
>                                                                               
>      .AsSet
> ();
>                                                                              
> });
>             discrimination.SubClass<Customer>((Int16)
> PersonType.Customer, m => { });
>         }
>     }
>
> Everything was working before changing to AutoMapping.
>
> Now I'm trying to make it work with AutoMapping.
--~--~---------~--~----~------------~-------~--~----~
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