hibernate could not get next sequence value

后端 未结 11 1438
夕颜
夕颜 2020-11-29 23:32

i have gwt application connect to postgres DB at the backend, and a java class \'Judgement\' mapping the table \'judgements\' in DB, when i tried to persistent a judgement i

11条回答
  •  悲哀的现实
    2020-11-30 00:31

    Please use the following query and alter your table : CREATE SEQUENCE user_id_seq START 1; ALTER TABLE product.users ALTER COLUMN user_id SET DEFAULT nextval('user_id_seq'); ALTER SEQUENCE users.user_id_seq OWNED BY users.user_id;

    and use the this in your entity class

    @GeneratedValue(strategy = GenerationType.SEQUENCE,generator="user_id_seq")

提交回复
热议问题