allocationSize Property of Sequence Generator
In previous releases, specifying the allocationSize property of sequence generator affected only sequence definition in the database.
During schema creation, the INCREMENT BY clause of CREATE SEQUENCE statement always had a value of 1 and on DB2, Oracle and PostgreSQL databases a CACHE clause was added with the value of allocationSize property.
Such a statement caused sequence values being cached in the database.
Starting with OpenJPA 2.2.0, sequence values are cached in the jvm memory and the allocationSize property determines size of that cache.
The CACHE clause is no longer used, instead the INCREMENT BY clause gets its value equal to the allocationSize property.
Such a strategy reduces the number of database roundtrips required for retrieving sequence values considerably.
In order for the existing applications to work with OpenJPA 2.2.0, you have to manually recreate or redefine sequences, specifying the correct INCREMENT BY value and, possibly, correct initial sequence value.
Note that the default value of the allocationSize property is 50 and that value is used if the property is not specified.
The requirement for sequence modification applies to all databases that support sequences, regardless of the CACHE clause being supported.
The only exception is Firebird database - since with this database the increment step is determined during sequence value fetch, no migration activity is needed.
To maintain the old behavior of sequence generator in OpenJPA 2.2.0, you can:
-
Set the
allocationSizeproperty value to 1. -
Additionally, if the
CACHEclause has to be emitted in sequence definition, this can be accomplished by overriding the DBDictionary.getCreateSequenceSQL method.