This code snippet is from SequenceHiLoGenerator.cs, trunk version.
90 if (lo > maxLo)
91 {
92 long hival =
Convert.ToInt64(base.Generate(session, obj));
93 lo = 1;
94 hi = hival * (maxLo + 1);
95 if (log.IsDebugEnabled)
96 log.Debug("new hi value: " + hival);
97 }
98 return IdentifierGeneratorFactory.CreateNumber(hi +
lo++, returnClass);
This code inserts maxLo rows for each hi, then skips one number for
every maxLo numbers. TableHiLoGenerator.cs had the same issue until
this was fixed in r3229, NH-1209, but the issue remains in
SequenceHiLoGenerator.
For hi=0, TableHiLoGenerator inserts maxLo rows, but with the fix, for
all other values of hi, (maxLo+1) rows are inserted. This behavior is
not consistent with Fabio's description in a comment on his blog:
http://fabiomaulo.blogspot.com/2009/02/nh210-generators-behavior-explained.html?showComment=1235702700000#c2007756876039894235
(comment was made after the fix)
The point I'm trying to make is that in various places on the
Internet, from time to time it is mentioned that if you need to
generate ids for such a table outside of NHibernate, for instance in a
database patch script, you could implement the HiLo-algorithm
yourself. But I am unable to find a correct and official documentation
of the algorithm used. IMHO pseudo-code (or similar) for this should
be in the reference documentation, section 5.1.4.2. Hi/Lo Algorithm.
/Oskar