Next thing you know you will suggest that everything is not really a
"is a" relationship (pun intended) and that what we learn in most OO
classes is *gasp* horribly wrong.

:)

On Fri, Aug 6, 2010 at 12:16 PM, Fabio Maulo <[email protected]> wrote:
> The problem is not the mapping but the concept of OOP.
> Let me show another case:
> Animal
> Dog : Animal
> Cat : Animal
> In the DB I have an Animal with ID 1 that is a Dog and a Cat.
> On Fri, Aug 6, 2010 at 11:50 AM, 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.
>>
>
>
>
> --
> Fabio Maulo
>
> --
> 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.
>



-- 
Les erreurs de grammaire et de syntaxe ont été incluses pour m'assurer
de votre attention

-- 
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.

Reply via email to