Search code examples
c#nhibernatenhibernate-mapping

Are HiLo IDs unique across different tables?


I have two different classes that map to two different database tables. IDs are created by NHibernate using the HiLo generator:

<generator class="hilo">
    <param name="table">uid</param>
    <param name="column">column</param>
</generator>

Are the IDs unique across both tables if I use the same table and column parameters for both mappings? If not, how can I achieve this?


Solution

  • NHibernate will distribute unique ids among all these tables, which use the same setting (table and column)

    If we want to have different id rows/sets, we can use another param:

    <param name="where">TableName='CmsLogin'</param>
    

    see more here:

    What are all the NHibernate HiLo generator params?