0

I have a database that uses sequence id generators. I need to perform a one time migration of large amount of data. I'm using NHibernate to do the job, because the migration logic is quite complicated.

Also I don't want this operation to last ages, so I would like to make use of batching.

Is there any Id strategy that can use sequence as an input, generate all the needed id's without contacting the database and then update the sequence at the end to enable normal usage by another application?

No other application will be running when the migration is performed.

kubal5003
  • 7,186
  • 8
  • 52
  • 90
  • hilo? with a large lo set? Although I am not sure how you will change this for the normal app to run without rebuilding the session factory... Although this might not be an issue if it runs solely on its own. – Rippo Jan 23 '13 at 14:59

1 Answers1

0

I think HiLo is perfect for your requirement.

You can find HiLo generator documentation here: http://nhibernate.info/doc/nh/en/index.html

Owen Pauling
  • 11,349
  • 20
  • 53
  • 64
Doan Van Tuan
  • 525
  • 3
  • 11
  • HiLo does not generate subsequent values like the sequence does nor it updates the sequence. I've already implemented my own solution based on the sequence generator - it contacts the database to set the sequence value to current+500 and the rest is similar to HiLo - incrementing a variable and performing a request for a new value if we've already used the pool. – kubal5003 Jan 24 '13 at 07:05
  • Cool, I missed that part. I did not use sequence or identity strategy for a long time, so I just forgot that for HiLo, one increment in the sequence is enough for multiple object. – Doan Van Tuan Jan 24 '13 at 17:00
  • That is the power of HiLo :) There's also the SeqHiLo strategy to use sequence instead of a table to save the high values, but that one was also not an option here. – kubal5003 Jan 25 '13 at 11:36