Assigned id usages in Nhibernate (ORM’s)
Why are assigned id’s frowned upon in the 开发者_StackOverflow社区Nhibernate world? Is there a particular disadvantage to using it?
NHiberante uses ID for caching entities in first level cache and Id is used to check if an entity is trancident or persisted. When you call SaveOrUpdate method NHibernate won't be able do determine if this entity new or it must be updated.
Also if you suddelny change ID of the entity, and save it - you can update wrong row in the data base.
精彩评论