3

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

1 Answer 1

4

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

Sign up to request clarification or add additional context in comments.

3 Comments

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: Would it really be that big of a deal if you had the UserId and a boolean property indicating that they're an admin?
@Rune: have a look at the docs: 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...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.