Caused by: org.hibernate.MappingException: The increment size of the [MY_SEQ] sequence is set to [50] in the entity mapping while the associated database sequence increment size is [1].

While upgrading from hibernate 3 to hibernate 5, this was one of the issues.

Here is how id fields were defined in hibernate 3.

@GeneratedValue(strategy=GenerationType.AUTO, generator="my_seq_gen")
@SequenceGenerator(name="my_seq_gen", sequenceName="MY_SEQ")
private long id;

So now, I added allocationSize = 1 to resolve the issue

@GeneratedValue(strategy=GenerationType.AUTO, generator="my_seq_gen")
@SequenceGenerator(name="my_seq_gen", sequenceName="MY_SEQ", allocationSize = 1)
private long id;

And for new Ids I used the below declaration

name = "MySequenceGenerator",
strategy = "",
parameters = {
@Parameter(name = "sequence_name", value = "MySequence"),
@Parameter(name = "initial_value", value = "1"),
@Parameter(name = "increment_size", value = "1")
@GeneratedValue(generator = "MySequenceGenerator")
private Long id = null;

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.