It's a judgement call really - personally, I'd be inclined to use an
additional surrogate key because it'll probably make things easier
programatically.

 

If this is your domain entity, I'd suggest a structure like this:

 

UserTagBookmark {

                Guid Id { get; protected set; }

                User Owner { get; set; }

                Tag Tag { get; set; }

                Bookmark Bookmark { get; set; }

                string Title { get; set; }

}

 

Note that the properties are the actual related entities, as opposed to
ID's; if they're immutable then I'd mark them as 'protected set' and add
a parameter to the public constructor to assign them, e.g.

 

protected UserTagBookmark() {}
// NH calls this when reading the entity

public UserTagBookmark(User owner) { ... }
// Your code calls this to create a new instance that's immutably
associated w/ the owner

 

/Pete

 

From: [email protected] [mailto:[email protected]] On
Behalf Of Mr.nuub
Sent: 16 December 2013 12:45
To: [email protected]
Subject: [nhusers] Should I add an extra surrogate key to this table?

 

I have the following table:

UserTagBookmark
- UserId
- TagId
- BookmarkId
- Title

Some people say that I should add an extra surrogate key to this table
because NHibernate does not work well with composite keys.

Like this:

UserTagBookmark
- Id
- UserId
- TagId
- BookmarkId
- Title

Is this true?

-- 
You received this message because you are subscribed to the Google
Groups "nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/groups/opt_out.

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to