Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nhibernate Conformist Mapping "Unable to determine type..."

The class:

    public class SOPProcess : ISOPProcess
{
    public virtual Guid Id { get; set; }
    public virtual SOP SOP { get; set; }
    public virtual ProcessType Type { get; set; }       

    public virtual SOPProcessInput Input { get; set; }
    public virtual SOPProcessOutput Output { get; set; }
    public virtual SOPProcessMeasures Measures { get; set; }

    public virtual decimal YieldFactor { get; set; }

    public virtual SOPProcess PreviousProcess { get; set; }
    public virtual SOPProcess NextProcess { get; set; }
}

The Mapping:

public class SOPProcessMap : ClassMapping<SOPProcess>
{
    public SOPProcessMap()
    {
        Id(s => s.Id, i => i.Generator(Generators.GuidComb));

        Property(s => s.YieldFactor);           

        ManyToOne(s => s.SOP, m =>
                                {
                                    m.Column("SopId");
                                    m.Cascade(Cascade.All);
                                });

        ManyToOne(s => s.Type, m =>
                                {
                                    m.Column("ProcessTypeId");
                                    m.Cascade(Cascade.All);
                                });

        ManyToOne(s => s.NextProcess, m =>
                                        {
                                            m.Column("NextProcessId");
                                            m.Cascade(Cascade.All);
                                        });

        ManyToOne(s => s.PreviousProcess, m =>
                                            {
                                                m.Column("PreviousProcessId");
                                                m.Cascade(Cascade.All);
                                            });
    }
}

The Error:

NHibernate.MappingException: Could not determine type for: MES.ProcessManager.SOP.SOPProcess, MES.ProcessManager, for columns: NHibernate.Mapping.Column(id)

I hope it's something simple, this is my first project using the Conformist mapping, so maybe I'm just overlooking something.

like image 687
tom.dietrich Avatar asked Sep 07 '11 19:09

tom.dietrich


2 Answers

From our discussion on the nhusers mailing list.

I ran across the same problems.

You haven't defined the type of relationship. See the line action => action.OneToMany()); in the mapping below.

public class SportMap : ClassMapping<Sport>
{
    public SportMap()
    {
        Id(x => x.Id, map =>
        {
            map.Column("Id");
            map.Generator(Generators.GuidComb);
        });

        Property(x => x.Name, map =>
        {
            map.NotNullable(true);
            map.Length(50);
        });

        Bag(x => x.Positions, map =>
        {
            map.Key(k => k.Column(col => col.Name("SportId")));
            map.Cascade(Cascade.All | Cascade.DeleteOrphans);
        },
        action => action.OneToMany());

        Property(x => x.CreateDate);
        Property(x => x.CreateUser);
        Property(x => x.LastUpdateDate);
        Property(x => x.LastUpdateUser);
    }
}
like image 150
Fran Avatar answered Nov 14 '22 07:11

Fran


It turned out that the problem was in my Set mappings in other classes. If you don't specify the action for the mapping, it throws this (misleading) error.

like image 38
tom.dietrich Avatar answered Nov 14 '22 08:11

tom.dietrich