title: Force TableGenerator with allocationSize to skip to next interval
body: <p>I have a JPA entity with a TableGenerator with allocationSize=25. If I were to manually update the TableGenerator table and give it a new value for the next ID start range, it won't have an effect until the current range has passed.</p>
  
  <p>For example, if the current TableGenerator table value is 10, I'd start to get entity IDs of 250, 251, 252, etc. At 255, I change the TableGenerater table value to 20. However, the next ID will still be 256, 257, all the way up to 274, <em>then</em> the next ID would be 500.</p>
  
  <p>This is natural, of course - but I'm wondering, is there a way to tell Hibernate to, for this moment, ignore the current interval and start assigning IDs from whatever's in the TableGenerator table?</p>
  
  <hr>
  
  <p>So, to answer the big <em>why</em>, in my particular case:</p>
  
  <p>I'm working on a test automation tool for my team's product which, for one thing, is able to setup test data through a running system (using client applications, APIs, etc). The test data configurations (let's call them testdatas) are defined such that several testdatas may be used together for a particular test case/test suite.</p>
  
  <p>Now, once a testdata has been run, the tool will extract the entered data from the db into SQL insert statements, and stow them away into files. There are several reasons for this, but mainly it's about performance - if I want to run 100 test cases with a certain testdata, I'd only really care about the testdata being inserted "manually" once, and then each time I reset, I may take the much faster route of inserting the test data directly into the database.</p>
  
  <p>However, as I said, several testdatas may be used together. What if testdata01 and testdata02 both affect the same tables? The extracted SQL insert statements will not contain the data for only that particular testdata, if another one has already been run beforehand.</p>
  
  <p>A simple solution to this is to reserve an interval of IDs for each testdata. testdata01 has interval [10000, 20000), testdata02 has interval [20000, 30000), etc, for each table. This was easy to implement - before running each testdata, simply update all TableGenerator tables to the lower bound of the testdata's ID interval - then, after running the testdata setup, extract only the rows with ID within the interval.</p>
  
  <p>This works great, and makes sure that there are never any clashes in IDs between testdatas, and that the exported SQL for each testdata only contains data for that particular testdata, regardless of what else may be in the database at the time. However, this one thing where allocationSize is not 1 messes things up - entries may still appear outside of the reserved ID interval for the given entity, even though we've updated updated that entity's TableGenerator.</p>
  
  <p>So, in short, what I'd like to do is, after updating the TableGenerator tables and before starting to run a testdata setup, I'd like to tell Hibernate that for each entity, next time you generate an ID, disregard whatever next value you would like to generate from that TableGenerator's range, and instead check the TableGenerator table in the database for which range to use next.</p>