I have this domain hierarchy:

User -> EntityWithAuditDate -> Entity

Here is the domain: (simplified)

    public class User : EntityWithAuditDate
    {
        public User(){}

        public virtual string Name { get; set; }

    }

        public abstract class EntityWithAuditDate : Entity
        {
                public EntityWithAuditDate() { }

                public virtual DateTime? CreatedAt { get; set; }
        }

And the mapping(simplified):

        <class name="User" table="Users" abstract="false">
                <id name="Id" type="Int32" column="UserId">
                        <generator class="identity" />
                </id>
                <property name="Name" type="String"/>
                <property name ="CreatedAt"/>
        </class>

When I ran a mapping integration unit test (http://ayende.com/Blog/
archive/2006/08/09/NHibernateMappingCreatingSanityChecks.aspx), I got
this error:

----------------------------------
Tests.AltNetTime.Data.NHibernateMaps.MappingIntegrationTests.CanConfirmDatabaseMatchesMappings:
FluentNHibernate.Cfg.FluentConfigurationException : An invalid or
incomplete configuration was used while creating a SessionFactory.
Check PotentialReasons collection, and InnerException for more detail.

  * Database was not configured through Database method.

  ----> FluentNHibernate.Cfg.FluentConfigurationException : An invalid
or incomplete configuration was used while creating a SessionFactory.
Check PotentialReasons collection, and InnerException for more detail.

  * Database was not configured through Database method.

  ----> NHibernate.MappingException : Could not compile the mapping
document: (XmlDocument)
  ----> NHibernate.DuplicateMappingException : Duplicate class/entity
mapping AltNetTime.Core.User
TearDown : System.Reflection.TargetInvocationException : Exception has
been thrown by the target of an invocation.
  ----> System.Collections.Generic.KeyNotFoundException : The given
key was not present in the dictionary.
------------------------------------

The unit test passed if the User class inherits from Entity instead.
Also, I had to remove the CreatedAt property from the mapping file.
Apparently, there was something wrong with the EntityWithAuditDate
class. I am not sure what caused the duplicate class/entity mapping.
Any ideas?

Thanks.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to nhusers@googlegroups.com
To unsubscribe from this group, send email to 
nhusers+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to