Yeah, I already have those relationships you mention regarding users,
applications and roles.

I should probably have explained with a little more detail my need for those
UserAppN tables. They are needed since every application will need somewhat
different data. In some applications I need to know the e-mail of the
person, in others I need to have a photo, in others I need their computer
name, etc... I could probably put all that information into a single table
and use another inheritance strategy, but I'm not sure if it'll help me
solve my problem. What I'm trying to accomplish is to take advantage of
polymorphism so I won't have code like if(string.IsNullOrEmpty(user.Email))
... to find out the 'type' of user and its operations.

I think I'll be going down the path you mention, having several one-to-one
relationships through composition instead of inheritance, but I was
wondering if there was a way to insert the information of those UserAppN
tables and relate them to an existing User, without having to set ID's
directly.

On Tue, Aug 31, 2010 at 09:49, Diego Mijelshon <[email protected]>wrote:

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

Reply via email to