NHibernate.MappingException: Could not determine type for: Id column

2,642 views
Skip to first unread message

Dietrich

unread,
Sep 7, 2011, 3:33:54 PM9/7/11
to nhu...@googlegroups.com
I'm on my first project using Conformist by-code mapping, and I hit a snag.

Basically, I've got this class

public class SOPProcess : ISOPProcess
	{
		public virtual Guid Id { getset; }
                [...]
        }

And I'm using this mapping 
	public SOPProcessMap()
	{
		Id(s => s.Id, i => i.Generator(Generators.GuidComb));
                [...]
        }

And I'm getting this error:

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

And now I'm scratching my head. 

What did I miss? 

fkne...@gmail.com

unread,
Sep 7, 2011, 3:38:02 PM9/7/11
to nhu...@googlegroups.com
I had this problem too, but it doesn't have to do with the mapping of your primary key.

Do you have a one to many mapping from another class?
> --
>
> You received this message because you are subscribed to the Google Groups "nhusers" group.
>
> To view this discussion on the web visit https://groups.google.com/d/msg/nhusers/-/bUgApYgVj28J.
>
> To post to this group, send email to nhu...@googlegroups.com.
>
> To unsubscribe from this group, send email to nhusers+u...@googlegroups.com.
>
>
> For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.
>
>
>
>

Dietrich

unread,
Sep 7, 2011, 4:04:54 PM9/7/11
to nhu...@googlegroups.com
Yes, the SOP object maps it, as so.

Set(s => s.Processes, m =>
	   {
		m.Table("SOPProcess");
		m.Cascade(Cascade.DeleteOrphans);
		m.Fetch(CollectionFetchMode.Subselect);
		   m.Key(k =>
		     {
			k.Column("SopId");
			k.ForeignKey("FK_SOPProcess_SOP");
	             });
         });
I've had trouble finding solid documentation on this stuff, so please point out my dumb mistakes.

fkne...@gmail.com

unread,
Sep 7, 2011, 4:15:24 PM9/7/11
to nhu...@googlegroups.com
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);

}
}



On , Dietrich <tom.di...@gmail.com> wrote:
> --
>
> You received this message because you are subscribed to the Google Groups "nhusers" group.
>
> To view this discussion on the web visit https://groups.google.com/d/msg/nhusers/-/_Lzf3fkUBLUJ.

Dietrich

unread,
Sep 7, 2011, 4:24:48 PM9/7/11
to nhu...@googlegroups.com
Adding the action map to all of the Set mappings got me past that error, thanks. Why is that not a requirement in the mapping? 

Fabio Maulo

unread,
Sep 8, 2011, 7:06:55 PM9/8/11
to nhu...@googlegroups.com
Because yo may have an event-handler or a custom IModelInspector managing the situation.
For example have a look to the code of the ConventionModelMapper 
Reply all
Reply to author
Forward
0 new messages