Home  /  Questions  /  Question

128   96.7
Mar 09, 2011

What is the use of the Hi/Lo method in NHibernate?

Hello NHibernate gurus. I have worked with NHibernate for a relavitely short time and have a question.

My understanding is that Hi/Lo is used to generate auto-increment numbers for primary keys. But I cannot think of a real-world situation where you would need this. Why not just rely on the underlying database identity or autonumber facilities?  And, does this not interfere with the database generated autonumbers (Identities)?


1,128   99.9
Mar 09, 2011
The primary use that I can think of when using hi/lo is in a disconnected state. Meaning a client can request a hi number and then generate as many lo numbers as it needs when disconnected.

There is also a performance gain, basically it's less chatter between the client and the database.
See post here -> http://nhforge.org/blogs/nhibernate/archive/2009/03/20/nhibernate-poid-generators-revealed.aspx