From 2ee6b659380ac3eb41e2deeacff9fb46646f13a3 Mon Sep 17 00:00:00 2001 From: Johannes Beck Date: Sat, 10 Feb 2024 12:16:20 +0100 Subject: [PATCH] Fix sequence in DDL --- etc/create-postgresql.sql | 3 ++- src/main/docker/x1-postgres-stomp-test/sql/ddl.sql | 4 ++-- src/main/java/x1/stomp/model/Share.java | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/etc/create-postgresql.sql b/etc/create-postgresql.sql index 71c0f80c..ce6235fa 100644 --- a/etc/create-postgresql.sql +++ b/etc/create-postgresql.sql @@ -8,6 +8,7 @@ CREATE TABLE stocks.share ( CONSTRAINT share_pkey PRIMARY KEY (id) ); +CREATE SEQUENCE stocks.share_seq INCREMENT BY 50; + CREATE UNIQUE INDEX idx_key ON stocks.share (key); CREATE INDEX idx_name ON stocks.share (name); -CREATE SEQUENCE stocks.hibernate_sequence; diff --git a/src/main/docker/x1-postgres-stomp-test/sql/ddl.sql b/src/main/docker/x1-postgres-stomp-test/sql/ddl.sql index 54199e23..ce6235fa 100644 --- a/src/main/docker/x1-postgres-stomp-test/sql/ddl.sql +++ b/src/main/docker/x1-postgres-stomp-test/sql/ddl.sql @@ -1,7 +1,5 @@ CREATE SCHEMA stocks; -CREATE SEQUENCE stocks.hibernate_sequence; - CREATE TABLE stocks.share ( id bigint NOT NULL, key character varying(25) NOT NULL, @@ -10,5 +8,7 @@ CREATE TABLE stocks.share ( CONSTRAINT share_pkey PRIMARY KEY (id) ); +CREATE SEQUENCE stocks.share_seq INCREMENT BY 50; + CREATE UNIQUE INDEX idx_key ON stocks.share (key); CREATE INDEX idx_name ON stocks.share (name); diff --git a/src/main/java/x1/stomp/model/Share.java b/src/main/java/x1/stomp/model/Share.java index f15cb9fb..7aaec5db 100644 --- a/src/main/java/x1/stomp/model/Share.java +++ b/src/main/java/x1/stomp/model/Share.java @@ -45,7 +45,7 @@ public Share(@NotNull @Size(min = 1, max = 25) @Pattern(regexp = "[A-Z0-9.]*", } @Id - @GeneratedValue(strategy = GenerationType.SEQUENCE) + @GeneratedValue(strategy = GenerationType.AUTO) @JsonIgnore @XmlTransient private Long id;