Joined subclasses not picked up when base type is an interface

1 view
Skip to first unread message

Robert Byrne

unread,
Oct 21, 2009, 4:30:21 AM10/21/09
to Fluent NHibernate
With a (pretty simplified) model like the following:

public interface IAssignee {
int Id { get; set; }
}

public class User : IAssignee {
//other properties
}

public class Group : IAssignee {
//other properties
}

Im mapping it along these lines:

public class AssigneeMap : ClassMap<IAssignee> {
public AsigneeMap() {
Table("Assignee");
Id(e => e.Id);
}
}

public class UserMap : SubclassMap<User> {
public AsigneeMap() {
Table("User");
KeyColumn("Id");
//other mappings..
}
}

public class GroupMap : SubclassMap<Group> {
public AsigneeMap() {
Table("Group");
KeyColumn("Id");
//other mappings..
}
}

The problem is that the two subclass mappings are not being included
in the generated mapping xml. I've tracked this down (I think) to
SeperateSubclassVisitor.cs. The method SortByDistanceFrom doesn't seem
to work if the parent type is an interface.

Would there by any problems adding a check around line 87 in that
class that special cases this situation. That is, if the parent type
is an interface, and the subclass providers type implements it, assume
that theres a relationship with a 'distance' of 0 between them?

Eric Ridgeway

unread,
Oct 21, 2009, 9:53:21 AM10/21/09
to fluent-n...@googlegroups.com

If you were to use an actual base class and not an interface this would work. The intent is to generate maps for subclasses not interface implementers.

Robert Byrne

unread,
Oct 21, 2009, 1:13:50 PM10/21/09
to fluent-n...@googlegroups.com
I agree, a base class would be better, but a common base class isn't possible in this situation.

The interface itself is explicitly mapped. This is something thats fully supported in NHibernate, should it not be supported here too?

2009/10/21 Eric Ridgeway <ang3...@gmail.com>



--
Regards,

Robert Byrne,
CTO, Iceberg

www.geticeberg.com

Eric Ridgeway

unread,
Oct 21, 2009, 2:55:28 PM10/21/09
to fluent-n...@googlegroups.com

So why can't you implement Assignee : Iassignee?

On Oct 21, 2009 10:14 AM, "Robert Byrne" <kap...@gmail.com> wrote:

I agree, a base class would be better, but a common base class isn't possible in this situation.

The interface itself is explicitly mapped. This is something thats fully supported in NHibernate, should it not be supported here too?

2009/10/21 Eric Ridgeway <ang3...@gmail.com>

> > If you were to use an actual base class and not an interface this would work. The intent is to ...




--
Regards,

Robert Byrne,
CTO, Iceberg

www.geticeberg.com

--~--~---------~--~----~------------~-------~--~----~ You received this message because you are su...

Robert Byrne

unread,
Oct 21, 2009, 4:44:10 PM10/21/09
to fluent-n...@googlegroups.com
Because the classes involved are already deriving from other classes, theres no common base between them.

I'm fixing up the generated mapping model manually for now, so its not a showstopper for me anymore. If anyone else runs into this we can patch it fairly easily from what I can see.

2009/10/21 Eric Ridgeway <ang3...@gmail.com>

So why can't you implement Assignee : Iassignee?

On Oct 21, 2009 10:14 AM, "Robert Byrne" <kap...@gmail.com> wrote:

I agree, a base class would be better, but a common base class isn't possible in this situation.

The interface itself is explicitly mapped. This is something thats fully supported in NHibernate, should it not be supported here too?

2009/10/21 Eric Ridgeway <ang3...@gmail.com>

> > If you were to use an actual base class and not an interface this would work. The intent is to ...




--
Regards,

Robert Byrne,
CTO, Iceberg

www.geticeberg.com


Reply all
Reply to author
Forward
0 new messages