java - JPA does not use sequence -


i have created sequence in database (postgresql) , have following annotations in domain model. using jpa. however, when invoke web service (rest) without id in object want create throws constraint error. shouldn't use value sequence below?

@id @sequencegenerator(name = "user_seq", sequencename = "user_seq", allocationsize = 1) @generatedvalue(strategy = generationtype.identity, generator = "user_seq") private int id; 

caused by: org.hibernate.exception.constraintviolationexception: not execute statement caused by: org.postgresql.util.psqlexception: error: null value in column "id" violates not-null constraint

when value comes database sequence, generationtype.sequence should used strategy. generationtype.identity used identity columns.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -