Using hilo is pretty easy but I expected that the hilo table would contain
the last given id.

Take the following scenario:

hilo(myentity:1)

Applications starts and retrieves a hilo key range for myentity:

hilo(myentity:2)

Application runs out of keys for myentity and fetches new range:

hilo(myentity:3)




This is how it currently works AFAIK but this is always the case apart from
the key range size. So the above scenario is always also true when I specify
a range of 5,10,25,50,100 or 1000.

Range 100:

hilo(myentity:1) => 0..99
hilo(myentity:2) => 100..199
hilo(myentity:3) => 200..299


Range 25:

hilo(myentity:1) => 0..24
hilo(myentity:2) => 25..49
hilo(myentity:3) => 50..74




If I want to adjust the rangesat a later stage then I also need to update
the table hilo column values.

For example, lets say I had a range configured for 100 keys and want to set
this to 10.

hilo(myentity:45) => 4400..4499

hilo(myentity:450) => 4490..4499



This means that when you change the key range you also need to adjust
(divide or multiply) the according column value in the hilo table.

new hilo value = current hilo value * (old range size / new range size)

new hilo value = 45 * ( 100 / 10 ) = 45 * 10 = 450



I could not find documentation about this so maybe it is useful to add this
to the nhibernate wiki.


Is it possible to store the last key of the range? This would mean that you
could much change the key range size much easier.


Range 100:

hilo(myentity:99) => 0..99
hilo(myentity:199) => 100..199
hilo(myentity:299) => 200..299

Change it to 25:

hilo(myentity:324) => 300..324
hilo(myentity:349) => 325..349
hilo(myentity:374) => 350..374

Then change it to 10:

hilo(myentity:384) => 375..384
hilo(myentity:394) => 385..394
hilo(myentity:404) => 395..404



This change would also mean that I could use the same hilo column for
different entities so that each entity has a unique int key accross all
tables but each entity could have a different hilo key range configured.

-- 
Ramon

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to