Ok, that looks fine. What are your GetAllTeachers and GetAllPolicemans doing?
On Aug 6, 4:12 pm, Luka <[email protected]> wrote: > public class PersonMapping : ClassMap<Person> > { > public PersonMappiing() > { > Table("People"); > Id(x => x.Id); > Map(x => x.Name); > } > > } > > public class TeacherMapping : SubclassMap<Teacher> > { > public TeacherMapping () > { > Table("Teachers"); > Map(x => x.School); > } > > } > > public class PolicemanMapping : SubclassMap<Policeman> > { > public PolicemanMapping() > { > Table("Policemans"); > Map(x => x.Dc); > } > > } > > On Aug 6, 4:50 pm, James Gregory <[email protected]> wrote: > > > > > Please show us your mappings. > > > You should have: > > > ClassMap<Person> > > SubclassMap<Teacher> > > SubclassMap<Policeman> > > > On Aug 6, 3:32 pm, Luka <[email protected]> wrote: > > > > ups my error! > > > > I have this problem: > > > public class Person:DomainBase<Person,int> > > > { > > > public string Name; > > > > } > > > > public class Teacher: Person > > > {... > > > > } > > > > public class Policeman:Person > > > {... > > > > } > > > > All classes are mapped using fluent nhibernate. > > > The inheritance is mapped by: SubClassMap<Person>. > > > > In code I am doing this: > > > IPersonRepository rep = > > > ObjectFactory.GetInstance<IPersonRepository>(); > > > var teachers = rep.GetAllTeachers(); > > > var policemans = rep.GetAllPolicemans(); > > > > The error I am getting is this: > > > > Object with id: 1 was not of the specified subclass: Policeman > > > (loading object was of wrong class [Teacher]). > > > > in the database I have i person with ID 1 that is a teacher and a > > > policeman. > > > > How to solve this problem? -- You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.
