views:

37

answers:

1

I have a users table that is updated by other systems. I have mapped the table to my users objects and that work great. As user data is owned by another system I don't want to change the structure of that table.

I want to add metadata to the user objects, but without changing the structure of the users table. I want to add a flag that tells me whether the user is an administrator or not. I think this flag could be stored in a table that only has one column which is the id of the user. whether a matching row is present would be represented as a boolean property on the user.

Is it possible to map this in NHibernate? I would like it so that I can update this directly through NHibernate.

+1  A: 

You should investigate the <join> mapping, usage is described in this article.

DanP
Hi Dan, as far sa I can see the join requires me to have a foreign key and a value in the table. What I was looking for was having a single column table just containing the foreign key and nothing else
Rune Juhl-Petersen
@Rune: Would it really be *that* big of a deal if you had the UserId and a boolean property indicating that they're an admin?
DanP
@Rune: have a look at the docs: http://nhforge.org/doc/nh/en/index.html#mapping-declaration-join I believe the "optional" setting may give you what you need; you'll have to have another column in there, but if it's null, a row won't exist...I think that's about as close as you'll get...
DanP
OK, thanks. I go for that approach then
Rune Juhl-Petersen