Postgres error in batch insert : relation "hibernate_sequence" does not exist position 17 Postgres error in batch insert : relation "hibernate_sequence" does not exist position 17 postgresql postgresql

Postgres error in batch insert : relation "hibernate_sequence" does not exist position 17


Try to annotate your id with @Id and @GeneratedValue(strategy = GenerationType.IDENTITY).

@Id@GeneratedValue(strategy = GenerationType.IDENTITY)private Long id;

UPDATE: It will only work if your id column was declared as SERIAL or BIGSERIAL types.


If you don't want to change your entity definition, then you need to create a sequence in your postgreSQL schema with name hibernate_sequence.

CREATE SEQUENCE hibernate_sequence START 1;

UPDATE:

You are missing second sequence generatef, which you defined for your entity, just add it like previous one:

CREATE SEQUENCE my_seq_gen START 1;

Sore useful tutorial:http://www.concretepage.com/hibernate/generatedvalue-strategy-generationtype-sequence-hibernate


I hope you get the answer but if you are still finding the answer this could be helpful.

I had same problem and resolved it annotating getter method of the id with @SequenceGenerator and @GeneratedValue.

@SequenceGenerator(name="seq-gen",sequenceName="MY_SEQ_GEN", initialValue=205, allocationSize=12)@GeneratedValue(strategy= GenerationType.SEQUENCE, generator="seq-gen")public int getId(){    return id;}