I'm using spring data JPA's sequence generator to assign primary keys to entities.
Model contains:
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seq_post")
@SequenceGenerator(name = "seq_post", allocationSize = 5)
private Long id;
The corresponding sequence definition(for SQL Server DB):
CREATE SEQUENCE dbo.seq_post START WITH 1 INCREMENT BY 5;
Since I wanted to start the ids from 100 instead of 1, so I updated the sql script to
CREATE SEQUENCE dbo.seq_post START WITH 100 INCREMENT BY 5;
And then I encountered the problem as mentioned here. I fixed it by the solution mentioned there.
This made me wonder, when I want the DB sequence to start from 1 then why does this issue does not happen? Based on the answer mentioned here I would expect the ids to not start from 1, but that does not happen. Why is that the case?