Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6358199
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:19:20+00:00 2026-05-24T23:19:20+00:00

There are a few overloads: GeneratedBy.HiLo(string maxLo); GeneratedBy.HiLo(string maxLo, Action<ParamBuilder> paramValues); GeneratedBy.HiLo(string table, string

  • 0

There are a few overloads:

GeneratedBy.HiLo(string maxLo);
GeneratedBy.HiLo(string maxLo, Action<ParamBuilder> paramValues);
GeneratedBy.HiLo(string table, string column, string maxLo);
GeneratedBy.HiLo(string table, string column, string maxLo, string where);
GeneratedBy.HiLo(string table, string column, string maxLo, Action<ParamBuilder> paramValues);

I understand conceptually what the hi/lo algorithm does. But what do these parameters do? I can’t find the documentation in Hibernate on what they actually do.

Is maxLo supposed to be a name, or a number? What are the paramValues? What are the purposes of table and column?

Example usage based on the NHibernate getting started tutorial:

public class StoreMap : ClassMap<Store>
{
    public StoreMap()
    {
        Id(x => x.Id).GeneratedBy.HiLo("something");
        Map(x => x.Name);
        HasMany(x => x.Staff)
            .Inverse()
            .Cascade.All();
        HasManyToMany(x => x.Products)
            .Cascade.All()
            .Table("StoreProduct");
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T23:19:22+00:00Added an answer on May 24, 2026 at 11:19 pm

    maxLo is the Lo-value of the HiLo.

    Depending on the frequency of inserts into the table you should specify the value as 10, 100, or 1000. If you specify the value as 10, NHibernate will grab the Hi value from the database and use the low value to generate your HiLo.

    If you insert often then you should specify a high Lo (such as 100 or 1000), if you insert less often then you should specify a low Lo. This is because a new Hi value is pulled from the database every time the session factory is created. If you have a current Hi of 5 with a Lo of 100, and have inserted 13 of 100 items, and you create a new Session Factory (from restarting the website, or app) then it will get a new Hi of 6, and you will have gaps from 513 to 600

    So if your Hi is currently 3, then it will generate values from 31 to 40. Likewise if your Lo is 1000, it will generates values from 3001 to 4000.

    The additional parameters allow you to specify a table where the Hi value is stored. By default NHibernate will generate this table for you if it’s configured to create/update the database, however the parameters allow you to setup the tables yourself.

    I wrote a blog post a while ago which shows Column per Hi, and Row per Hi.

    http://www.philliphaydon.com/2010/10/24/using-hilo-with-fluentnhibernate/

    Edit: Behaviour of a Lo such as 7

    HiLo is calculated as a range of numbers, for example if we have a Hi of 3, and a Lo of 10, the range is between:

    3*10 = 30 to 3*10+10 = 40

    So the session factory will have a range of 30 to 40, when you ask for an Id for an object it grabs it’s current value (30) and add’s 1. So the Id = 31. The next object will take 31+1 = 32. And this occurs until it reaches 40, at which point it goes to the database and asks for the next Hi.

    If you had two web servers, the second Web Server may have asked for the next Hi which was 4, which means the first Web Server will get 5.

    So your next range is 50 to 60.


    If the Lo was 7, we would get:

    0*7 = 0 / 0*7+7 = 7 = 1-7

    1*7 = 7 / 1*7+7 = 14 = 8-14

    2*7 = 14 / 2*7+7 = 21 = 15-21

    So it still works.

    But my personal opinion is it’s easier to work with whole values, 10, 100, 1000.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

It looks like there a few working solutions for using custom true type fonts
I know how to use locks in my app, but there still few things
There are a few ways to get class-like behavior in javascript, the most common
There are a few books about specific ORM products such as Hibernate or Linq
There are a few things that I almost always do when I put a
There are a few questions on SO already regarding LINQ pivots and while a
There are a few questions about configuring Apache for local development, such as this
There are a few APIs for grabbing the address book/contact list from the major
There are a few pages here addressing usage of jQuery with .net masterpages -
There are a few windows service projects in our codebase that follow this model,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.