Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I get the following error when using the below mappings:

NHibernate.MappingException: Association references unmapped class: GeoTriggers.Domain.Entities.ITrigger

Entities:

public class Profile
{
    public virtual int Id { get; set; }
    public virtual string Password { get; set; }
    public virtual string Username { get; set; }
    public virtual IList<ITrigger> Triggers { get; set; }        
}

public interface ITrigger
{
    int Id { get; set; }
    decimal Latitude { get; set; }
    decimal Longitude { get; set; }
    decimal Radius { get; set; }
}

public class EmailTrigger : ITrigger
{
    public virtual string RecipientAddress { get; set; }
    public virtual string SenderAddress { get; set; }
    public virtual string Subject { get; set; }
    public virtual string Body { get; set; }

    #region ITrigger Members

    public virtual int Id { get; set; }
    public virtual decimal Latitude { get; set; }
    public virtual decimal Longitude { get; set; }
    public virtual decimal Radius { get; set; }

    #endregion
}

Using the following class maps:

public sealed class ProfileMap : ClassMap<Profile>
{
    public ProfileMap()
    {
        HasMany(x => x.Triggers).Cascade.All();
    }
}

public sealed class TriggerClassMap : ClassMap<ITrigger>
{
    public TriggerClassMap()
    {            
    }    
}

public sealed class EmailTriggerClassMap : SubclassMap<EmailTrigger>
{
    public EmailTriggerClassMap()
    {            
    }
}

Using the following FluentNHibernate configuration:

FluentConfiguration fluent = Fluently.Configure(_configuration)
                .Mappings(
                    x => x.AutoMappings.Add(
                        AutoMap.Assemblies(typeof (TEntity).Assembly).Where(
                            assembly => assembly.Namespace.Contains("Entities"))));

All my entities are in a namespace that includes the word "Entities". I did this to avoid having to make all my entities inherit from a common base.

I am trying to keep my configuration to a minimum, so I have opted to allow Fluent NHibernate to run free with its default conventions. Normally, I don't even have class map files. But, now, since I'm trying to map a list of objects that implement a common interface, it has gotten sticky.

The error says that an association (I assume the one-to-many in the ProfileMap) references an unmapped class (ITrigger). According to the docs, it sounds like all I need to have is a class map for the base/interface and subclass maps for the implementations. I have that. What am I missing?

share|improve this question
    
i assume automapping is trying to map the list as hasmany but it should map it as hasAny. Can you define a mappingoverride for this? –  Firo Jul 25 '11 at 11:01

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.