the UoW is broken with identity, but in a subtle way. and in most cases 
it's not an issue.

your other option, besides guids is HiLo. this uses a long/int for the PK 
and ensures uniqueness. however there may be gaps in the keys, or the 
logically order isn't the PK order. but really PK shouldn't mean much 
outside of the DB, so it shouldn't be an issue. Because NH is not the only 
way to write data to the database, GUID would be a better choice over HiLo. 
Otherwise you have to implement the same HiLo algorithm for the other 
access points.

Identity breaks the UoW concept in NH because of how and when it calls the 
DB to get the ID. This is best explained by the articles you mentioned. But 
in a nutshell, NH shouldn't update the database until the transaction is 
committed (session flushed). try this. run NH without using a transaction 
or flush and you will see the database still get queried, because NH needs 
the ID from the database.

You also cannot take advantage of NH's batch writes with identity. This can 
be a powerful (and easy) performance booster when optimizing the queries 
and commands used by NH.

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/nhusers/-/fQj_1wm4xWAJ.
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