What you have there is not inheritance, it's definitely a has-a (or
has-many) relationship.
Perhaps even the most studied case of that kind of relationship.
In this case, a User has (or "corresponds to") zero, one or many
applications (or roles), so that should be the model.
You probably don't even need those UserAppN tables (if you do, then it might
be several one-to-one relationships)
Diego
On Tue, Aug 31, 2010 at 12:50, Yorch <[email protected]> wrote:
> Good afternoon,
>
> I'm facing a bit of a problem here regarding inheritance in NHibernate.
>
> I have an architecture where there's an User base class and a several
> derived user classes for different applications that are accessing the
> database (UserApp1, UserApp2, ..., UserAppN). I'm using the Table per
> subclass strategy, so it's a one-to-one association between the User table
> and each of the UserAppN tables.
>
> What I want to do is to first create and persist the information in the
> User class, and sometime after that create the information for each of the
> applications, depending on whether the user has access
> to it or not. The problem I'm facing is that I don't know the correct way
> to create a UserAppN from a User. I've been googling this for a while and
> haven't been able to find anything, so I hope you can help me.
>
> So, my question is this: how can I create a UserAppN from an already
> existent User, in code and in the database, and have them related? I'm about
> to "favor composition over inheritance" here, having a User instance in each
> of the UserAppN classes, but I'd also like to know if there's a way to solve
> my problem with inheritance.
>
> Thanks in advance.
>
> Jorge Vargas.
>
> --
> 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]<nhusers%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/nhusers?hl=en.
>
--
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.