Make @GeneratedValue start a sequence with a specific value
Solution 1:
You can define your entity like this:
@Entity
@Table(name = "users")
@SequenceGenerator(name = "sequence", sequenceName = "mySequence")
public class User {
@Id
@Column(name = "id")
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequence")
@Getter private Long id;
And then in your .sql file write insert queries like this:
INSERT INTO users values (select nextval('mySequence'), ...
select nextval('mySequence')
will give you next available value from sequence table
Solution 2:
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "your_custom_sequence")
@SequenceGenerator(name="your_custom_sequence", sequenceName = "MY_CUSTOM_SEQ", allocationSize=1)
and you can define your sequence in sql like CREATE SEQUENCE MY_CUSTOM_SEQ MINVALUE 1 START WITH 1 INCREMENT BY 1 CACHE 20 NOMAXVALUE;