Questions tagged [hilo]

HiLo algorithm used for generating Ids for databases

The basic idea is that you have two numbers to make up a primary key- a "high" number and a "low" number. A client can basically increment the "high" sequence, knowing that it can then safely generate keys from the entire range of the previous "high" value with the variety of "low" values.

For instance, supposing you have a "high" sequence with a current value of 35, and the "low" number is in the range 0-1023. Then the client can increment the sequence to 36 (for other clients to be able to generate keys while it's using 35) and know that keys 35/0, 35/1, 35/2, 35/3... 35/1023 are all available.

It can be very useful (particularly with ORMs) to be able to set the primary keys on the client side, instead of inserting values without primary keys and then fetching them back onto the client. Aside from anything else, it means you can easily make parent/child relationships and have the keys all in place before you do any inserts, which makes batching them simpler.

What's the Hi/Lo algorithm?

69 questions
2
votes
1 answer

NHibernate HiLo ID generator is performing a round-trip to the database per-row inserted

When I configure my application to use HiLo Id generation, I see one round-trip per row inserted in the database. All the documentation I've read has indicated that I should see far fewer round-trips. My objects are all generally configured…
JeffreyABecker
  • 2,724
  • 1
  • 25
  • 36
1
vote
1 answer

nhibernate hilo Id generator generates weird Id number

I am using nhibernate 3.2 mapping by convention. here's my code. in my hilo table, NextHi is 1. I delete all records in User table, then insert a new User there. Instead getting a really small number like 10 or 11, the first user I inserted has Id…
qinking126
  • 11,385
  • 25
  • 74
  • 124
1
vote
0 answers

Insert dependent Values with Fluent Migrator and EF Core HiLo

I have the following table: public class Category { public int Id{ get; set; } public string Name { get; set; } public int? ParentId { get; set; } public Category Parent { get; set; } } with the following mapping: public class…
wydy
  • 173
  • 14
1
vote
1 answer

UseHiLo EF Core 5 setting value to previous one

modelBuilder.HasSequence("SEQ_TEST").IncrementsBy(1); entity.Property(e => e.TestId) .HasPrecision(10) .HasColumnName("TEST_ID") .ValueGeneratedOnAdd() .UseHiLo("SEQ_TEST", "SCHEMA_NAME"); I can add 10 rows but for 11th row, its again reverting back…
user3838575
  • 115
  • 1
  • 6
1
vote
1 answer

Migrate Nhibernate Castle.ActiveRecord to EFCore HiLo

We're currently migrating our old OR Mapper to EF Core. Till now we used the http://www.castleproject.org/projects/activerecord or mapper with the HiLo algorithm. The explanations…
wydy
  • 173
  • 14
1
vote
1 answer

NHibernate, HiLo and many-to-many association

I have two entities, Role and Permission, each with its table in the database and properly set-up ID generation with a HiLo algorithm. This works fine. However, there is one more table in the database, ROLE_PERMISSION_ASSIGNMENT, simply containing…
twoflower
  • 6,788
  • 2
  • 33
  • 44
1
vote
2 answers

JPA hibernate with sequence stratery as legacy_hilo and multiple applications deployed

I'm using JPA with hibernate and have a bean defined like this. @Entity @Table(name = "ARTICLE") @GenericGenerator( name = "ARTICLE_GEN", strategy = "sequence", parameters = { @Parameter(name =…
Fozix
  • 133
  • 3
  • 12
1
vote
1 answer

NHibernate: Recreate Database with SchemaExport

I have a question about correctly handling a recreation of a database. In my dev environment I often recreate the database by using _schemaExport.Drop(true, true); _schemaExport.Create(createResult, true); (I have to note, that I use the hilo…
David Rettenbacher
  • 5,088
  • 2
  • 36
  • 45
1
vote
1 answer

The Hibernate hilo strategy does not generate the values according to the next database sequence value

I have a jpa configuration like this: @Id //@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="seq_gen") @GeneratedValue(generator = "timedep_seq_gen") @GenericGenerator( name = "seq_gen", …
user2599052
  • 1,056
  • 3
  • 12
  • 27
1
vote
0 answers

Implementing Strongly Typed Ids and Hilo strategy via Entityframework core

I'm working on a project in which instead of using primitive types like Int as Id, "Strongly Typed" are used, like CategoryId object. I want to use EntityFramework Core alongside with HiLo strategy, but it seems that entityframework just supports…
Kasra
  • 11
  • 3
1
vote
1 answer

NHibernate Insert Error

I have just setup a Sql Server db using the same mappings and source data that have been working with SQLite, and getting the error below when I try to save a batch of test data. I suspect it is a hilo issue that SQLite doesn't catch but I can't…
Berryl
  • 12,471
  • 22
  • 98
  • 182
1
vote
1 answer

Implementing hilo (or seqhilo) in NHibernate and Oracle

I have a database (which I can not modify) with 6 tables in Oracle 11g. All tables have a OID artificial column for ID, and its type is RAW(16). The DBA answered me that they are in raw and not in integer because this way the IDs will be unique in…
Pedro Dusso
  • 2,100
  • 9
  • 34
  • 64
1
vote
1 answer

Could not read hilo value in NHibernate

For our ASP.NET MVC application we are seeing the following in our error log: IdentifierGenerationException could not read a hi value from table 'nhibernatehiloidentity' using the where clause (entity = '[table name]') The [table name] can vary.…
Adam Schentag
  • 61
  • 1
  • 3
1
vote
2 answers

Improvement on Hi-Lo Id generator

I have a hi-lo Id generator which I use in a multi-threaded environment. The generator can be called up to 100k times per second per thread I have a reasonably good (and safe) implementation which works fine. IdAllocator is the object that fetches…
Mike Q
  • 22,839
  • 20
  • 87
  • 129
1
vote
1 answer

GPRS Modem based data communication for Embedded Remote Client and Server

For SAGEM HiLo GPRS based data communication, it has TCP/IP stack and there are two ways to get connected: (1) Using basic GPRS commands and then ppp dialing to brings the modem to public network/Internet…
Pavan Kumar
  • 21
  • 1
  • 4