What's the reason behind the jumping GeneratedValue(strategy=GenerationType.TABLE) when not specifyi
- by joeduardo
Why do I need to add allocationSize=1 when using the @TableGenerator to ensure that the id wouldn't jump from 1, 2,... to 32,xxx, 65,xxx,... after a jvm restart?
Is there a design reason for the need to specify the allocationSize?
This snippet would produce the jumping ids
@Id
@GeneratedValue(strategy = GenerationType.TABLE)
private Long id;
Here's the modified snippet that produces the properly sequenced ids
@Id
@GeneratedValue(strategy = GenerationType.TABLE, generator = "account_generator")
@TableGenerator(name = "account_generator", initialValue = 1, allocationSize = 1)
private Long id;