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 -

Socket.connect doesn't throw exception in Android -

iphone - How do I keep MDScrollView from truncating my row headers and making my cells look bad? -