Reputation: 8314
I am using the TABLE GenerationType strategy for generating primary key values of a table. The starting value is 0 so I am expecting that the id values of the new rows added to the database will be sequential, i.e. 1 then 2 then 3 then 4 ... etc.
Actually what I am noticing that the values are incrementing but not in a sequential way. What I am having is something like: 1,2,3, 51, 52, 53, 54, 101, 102 ...
Why is this happening? Is there any way to control the incrementation of the primary key values? Thanks a lot
Upvotes: 1
Views: 484
Reputation: 42074
Increment can be controlled with allocationSize attribute in TableGenerator annotation. Documentation contains also usage example: http://docs.oracle.com/javaee/5/api/javax/persistence/TableGenerator.html
Upvotes: 2