Hi guys, thanks for the responses.

With identity because NH goes to the DB early at the point of
currentsession.save() I had to wrap a try/catch and rollback in the
catch around currentsession.save() as opposed to only having a try/
catch and rollback around currentsession.commit() which would work for
NH managed keys.

So to use identity I just needed to have more rollbacks around more
fails points so yes the problem is small.

cheers.

On Oct 28, 1:43 pm, Jason Meckley <[email protected]> wrote:
> 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 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