I would like to ask some help regarding database sequence created by Hibernate.
I have this annotation - the code below - in my entity class in order to have individual sequence for partners table. I expect that the sequence starts with 1000, because I insert test data into my database using import.sql during deploy and I would like to avoid the constraint violation. But when I want to persist data than I got the constraint violation exception and it informs me about the fact the partner_id = 2 already exists. It looks like I missed something.
@Id
@Column(name = "partner_id")
@SequenceGenerator(initialValue=1000,
allocationSize=1,
name = "partner_sequence",
sequenceName="partner_sequence")
@GeneratedValue(generator="partner_sequence")
private Long partnerId;
The generated sequence looks like this:
CREATE SEQUENCE partner_sequence
INCREMENT 1
MINVALUE 1
MAXVALUE 9223372036854775807
START 1
CACHE 1;
ALTER TABLE partner_sequence
OWNER TO postgres;
I use postgres 9.1.
Did I miss something? This is the way how can I approach what I want?
Thanks for any help in advance!