From e3497b06b54646afaaca73cb3c8c759240226729 Mon Sep 17 00:00:00 2001 From: Jens Schauder Date: Mon, 15 Dec 2025 11:21:39 +0100 Subject: [PATCH 1/2] 2199 - Prepare branch --- pom.xml | 2 +- spring-data-jdbc-distribution/pom.xml | 2 +- spring-data-jdbc/pom.xml | 4 ++-- spring-data-r2dbc/pom.xml | 4 ++-- spring-data-relational/pom.xml | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pom.xml b/pom.xml index 2b5127b5dc..277b4a2ddd 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.springframework.data spring-data-relational-parent - 4.1.0-SNAPSHOT + 4.1.0-2199-SNAPSHOT pom Spring Data Relational Parent diff --git a/spring-data-jdbc-distribution/pom.xml b/spring-data-jdbc-distribution/pom.xml index 824e70541b..5fdf260a72 100644 --- a/spring-data-jdbc-distribution/pom.xml +++ b/spring-data-jdbc-distribution/pom.xml @@ -14,7 +14,7 @@ org.springframework.data spring-data-relational-parent - 4.1.0-SNAPSHOT + 4.1.0-2199-SNAPSHOT ../pom.xml diff --git a/spring-data-jdbc/pom.xml b/spring-data-jdbc/pom.xml index 87567d6220..03e1cf10a5 100644 --- a/spring-data-jdbc/pom.xml +++ b/spring-data-jdbc/pom.xml @@ -6,7 +6,7 @@ 4.0.0 spring-data-jdbc - 4.1.0-SNAPSHOT + 4.1.0-2199-SNAPSHOT Spring Data JDBC Spring Data module for JDBC repositories. @@ -15,7 +15,7 @@ org.springframework.data spring-data-relational-parent - 4.1.0-SNAPSHOT + 4.1.0-2199-SNAPSHOT diff --git a/spring-data-r2dbc/pom.xml b/spring-data-r2dbc/pom.xml index b8ac584eee..83f2f7137e 100644 --- a/spring-data-r2dbc/pom.xml +++ b/spring-data-r2dbc/pom.xml @@ -6,7 +6,7 @@ 4.0.0 spring-data-r2dbc - 4.1.0-SNAPSHOT + 4.1.0-2199-SNAPSHOT Spring Data R2DBC Spring Data module for R2DBC @@ -15,7 +15,7 @@ org.springframework.data spring-data-relational-parent - 4.1.0-SNAPSHOT + 4.1.0-2199-SNAPSHOT diff --git a/spring-data-relational/pom.xml b/spring-data-relational/pom.xml index 652ad2853d..e5cd661764 100644 --- a/spring-data-relational/pom.xml +++ b/spring-data-relational/pom.xml @@ -6,7 +6,7 @@ 4.0.0 spring-data-relational - 4.1.0-SNAPSHOT + 4.1.0-2199-SNAPSHOT Spring Data Relational Spring Data Relational support @@ -14,7 +14,7 @@ org.springframework.data spring-data-relational-parent - 4.1.0-SNAPSHOT + 4.1.0-2199-SNAPSHOT From 8332465ddfcf74b9d885fc3ae871139c01e6729f Mon Sep 17 00:00:00 2001 From: Jens Schauder Date: Mon, 15 Dec 2025 12:08:46 +0100 Subject: [PATCH 2/2] Removed is new check from id generation by sequence. The check prevented the id generation when there was a version property, since that was already set at the time of the check and therefore the check failed. Closes #2199 --- .../convert/IdGeneratingEntityCallback.java | 2 +- ...epositoryIdGenerationIntegrationTests.java | 28 +++++++++++ ...sitoryIdGenerationIntegrationTests-db2.sql | 9 ++++ ...ositoryIdGenerationIntegrationTests-h2.sql | 43 +++++++++++++--- ...itoryIdGenerationIntegrationTests-hsql.sql | 43 +++++++++++++--- ...ryIdGenerationIntegrationTests-mariadb.sql | 43 +++++++++++++--- ...toryIdGenerationIntegrationTests-mssql.sql | 49 ++++++++++++++++--- ...oryIdGenerationIntegrationTests-oracle.sql | 10 ++++ ...yIdGenerationIntegrationTests-postgres.sql | 45 ++++++++++++++--- 9 files changed, 239 insertions(+), 33 deletions(-) diff --git a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/IdGeneratingEntityCallback.java b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/IdGeneratingEntityCallback.java index 38d0338ba8..74c5cfff84 100644 --- a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/IdGeneratingEntityCallback.java +++ b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/IdGeneratingEntityCallback.java @@ -59,7 +59,7 @@ public Object onBeforeSave(Object aggregate, MutableAggregateChange aggr RelationalPersistentProperty property = entity.getRequiredIdProperty(); PersistentPropertyAccessor accessor = entity.getPropertyAccessor(aggregate); - if (!entity.isNew(aggregate) || delegate.hasValue(property, accessor) || !property.hasSequence()) { + if (delegate.hasValue(property, accessor) || !property.hasSequence()) { return aggregate; } diff --git a/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/repository/JdbcRepositoryIdGenerationIntegrationTests.java b/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/repository/JdbcRepositoryIdGenerationIntegrationTests.java index 95cc6dac55..29c7cbdd63 100644 --- a/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/repository/JdbcRepositoryIdGenerationIntegrationTests.java +++ b/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/repository/JdbcRepositoryIdGenerationIntegrationTests.java @@ -69,6 +69,7 @@ class JdbcRepositoryIdGenerationIntegrationTests { @Autowired SimpleSeqRepository simpleSeqRepository; @Autowired PersistableSeqRepository persistableSeqRepository; @Autowired PrimitiveIdSeqRepository primitiveIdSeqRepository; + @Autowired PrimitiveIdSeqWithVersionRepository primitiveIdSeqWithVersionRepository; @Autowired IdGeneratingEntityCallback idGeneratingCallback; @Test // DATAJDBC-98 @@ -173,6 +174,22 @@ void testInsertAggregateWithSequenceAndUnsetPrimitiveId() { assertThat(saved.id).isEqualTo(1L); // sequence starts with 1 } + @Test // DATAJDBC-2199 + @EnabledOnFeature(TestDatabaseFeatures.Feature.SUPPORTS_SEQUENCES) + void testInsertAggregateWithSequenceAndVersionField() { + + IdSeqWithVersion entity = new IdSeqWithVersion(); + entity.name = "some name"; + CompletableFuture afterCallback = mockIdGeneratingCallback(entity); + + IdSeqWithVersion saved = primitiveIdSeqWithVersionRepository.save(entity); + + // 1. Select from sequence + // 2. Actual INSERT + assertThat(afterCallback.join().id).isEqualTo(1L); + assertThat(saved.id).isEqualTo(1L); // sequence starts with 1 + } + @SuppressWarnings("unchecked") private CompletableFuture mockIdGeneratingCallback(T entity) { @@ -198,6 +215,8 @@ interface PersistableSeqRepository extends ListCrudRepository {} + interface PrimitiveIdSeqWithVersionRepository extends ListCrudRepository {} + record ReadOnlyIdEntity(@Id Long id, String name) { } @@ -251,6 +270,15 @@ static class PrimitiveIdSeq { } + static class IdSeqWithVersion { + + @Id + @Sequence(value = "seq_with_version_seq") private long id; + + private String name; + private Long version; + } + static class PrimitiveIdEntity { @Id private long id; diff --git a/spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository/JdbcRepositoryIdGenerationIntegrationTests-db2.sql b/spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository/JdbcRepositoryIdGenerationIntegrationTests-db2.sql index b4d471efdb..2349a1a38d 100644 --- a/spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository/JdbcRepositoryIdGenerationIntegrationTests-db2.sql +++ b/spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository/JdbcRepositoryIdGenerationIntegrationTests-db2.sql @@ -9,6 +9,8 @@ DROP TABLE PersistableSeq; DROP SEQUENCE persistable_seq_seq; DROP TABLE PrimitiveIdSeq; DROP SEQUENCE "primitive_seq_seq"; +DROP TABLE IdSeqWithVersion; +DROP SEQUENCE "seq_with_version_seq"; CREATE TABLE ReadOnlyIdEntity ( @@ -43,3 +45,10 @@ CREATE TABLE PrimitiveIdSeq NAME VARCHAR(100) ); CREATE SEQUENCE "primitive_seq_seq" START WITH 1; +CREATE TABLE IdSeqWithVersion +( + ID BIGINT NOT NULL PRIMARY KEY, + NAME VARCHAR(100), + VERSION BIGINT +); +CREATE SEQUENCE "seq_with_version_seq" START WITH 1; diff --git a/spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository/JdbcRepositoryIdGenerationIntegrationTests-h2.sql b/spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository/JdbcRepositoryIdGenerationIntegrationTests-h2.sql index 3db0d0db67..6da59affe2 100644 --- a/spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository/JdbcRepositoryIdGenerationIntegrationTests-h2.sql +++ b/spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository/JdbcRepositoryIdGenerationIntegrationTests-h2.sql @@ -1,12 +1,43 @@ -- noinspection SqlNoDataSourceInspectionForFile -CREATE TABLE ReadOnlyIdEntity (ID BIGINT GENERATED BY DEFAULT AS IDENTITY(START WITH 1) PRIMARY KEY, NAME VARCHAR(100)); -CREATE TABLE PrimitiveIdEntity (ID BIGINT GENERATED BY DEFAULT AS IDENTITY(START WITH 1) PRIMARY KEY, NAME VARCHAR(100)); -CREATE TABLE ImmutableWithManualIdentity (ID BIGINT PRIMARY KEY, NAME VARCHAR(100)); +CREATE TABLE ReadOnlyIdEntity +( + ID BIGINT GENERATED BY DEFAULT AS IDENTITY (START WITH 1) PRIMARY KEY, + NAME VARCHAR(100) +); +CREATE TABLE PrimitiveIdEntity +( + ID BIGINT GENERATED BY DEFAULT AS IDENTITY (START WITH 1) PRIMARY KEY, + NAME VARCHAR(100) +); +CREATE TABLE ImmutableWithManualIdentity +( + ID BIGINT PRIMARY KEY, + NAME VARCHAR(100) +); -CREATE TABLE SimpleSeq (ID BIGINT NOT NULL PRIMARY KEY, NAME VARCHAR(100)); +CREATE TABLE SimpleSeq +( + ID BIGINT NOT NULL PRIMARY KEY, + NAME VARCHAR(100) +); CREATE SEQUENCE simple_seq_seq START WITH 1; -CREATE TABLE PersistableSeq (ID BIGINT NOT NULL PRIMARY KEY, NAME VARCHAR(100)); +CREATE TABLE PersistableSeq +( + ID BIGINT NOT NULL PRIMARY KEY, + NAME VARCHAR(100) +); CREATE SEQUENCE persistable_seq_seq START WITH 1; -CREATE TABLE PrimitiveIdSeq (ID BIGINT NOT NULL PRIMARY KEY, NAME VARCHAR(100)); +CREATE TABLE PrimitiveIdSeq +( + ID BIGINT NOT NULL PRIMARY KEY, + NAME VARCHAR(100) +); CREATE SEQUENCE "primitive_seq_seq" START WITH 1; +CREATE TABLE IdSeqWithVersion +( + ID BIGINT NOT NULL PRIMARY KEY, + NAME VARCHAR(100), + VERSION BIGINT +); +CREATE SEQUENCE "seq_with_version_seq" START WITH 1; diff --git a/spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository/JdbcRepositoryIdGenerationIntegrationTests-hsql.sql b/spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository/JdbcRepositoryIdGenerationIntegrationTests-hsql.sql index 0494ffa81b..fd4dd18eb1 100644 --- a/spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository/JdbcRepositoryIdGenerationIntegrationTests-hsql.sql +++ b/spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository/JdbcRepositoryIdGenerationIntegrationTests-hsql.sql @@ -1,12 +1,43 @@ -- noinspection SqlNoDataSourceInspectionForFile -CREATE TABLE ReadOnlyIdEntity (ID BIGINT GENERATED BY DEFAULT AS IDENTITY(START WITH 1) PRIMARY KEY, NAME VARCHAR(100)); -CREATE TABLE PrimitiveIdEntity (ID BIGINT GENERATED BY DEFAULT AS IDENTITY(START WITH 1) PRIMARY KEY, NAME VARCHAR(100)); -CREATE TABLE ImmutableWithManualIdentity (ID BIGINT PRIMARY KEY, NAME VARCHAR(100)); +CREATE TABLE ReadOnlyIdEntity +( + ID BIGINT GENERATED BY DEFAULT AS IDENTITY (START WITH 1) PRIMARY KEY, + NAME VARCHAR(100) +); +CREATE TABLE PrimitiveIdEntity +( + ID BIGINT GENERATED BY DEFAULT AS IDENTITY (START WITH 1) PRIMARY KEY, + NAME VARCHAR(100) +); +CREATE TABLE ImmutableWithManualIdentity +( + ID BIGINT PRIMARY KEY, + NAME VARCHAR(100) +); -CREATE TABLE SimpleSeq (ID BIGINT NOT NULL PRIMARY KEY, NAME VARCHAR(100)); +CREATE TABLE SimpleSeq +( + ID BIGINT NOT NULL PRIMARY KEY, + NAME VARCHAR(100) +); CREATE SEQUENCE "simple_seq_seq" START WITH 1; -CREATE TABLE PersistableSeq (ID BIGINT NOT NULL PRIMARY KEY, NAME VARCHAR(100)); +CREATE TABLE PersistableSeq +( + ID BIGINT NOT NULL PRIMARY KEY, + NAME VARCHAR(100) +); CREATE SEQUENCE "persistable_seq_seq" START WITH 1; -CREATE TABLE PrimitiveIdSeq (ID BIGINT NOT NULL PRIMARY KEY, NAME VARCHAR(100)); +CREATE TABLE PrimitiveIdSeq +( + ID BIGINT NOT NULL PRIMARY KEY, + NAME VARCHAR(100) +); CREATE SEQUENCE "primitive_seq_seq" START WITH 1; +CREATE TABLE IdSeqWithVersion +( + ID BIGINT NOT NULL PRIMARY KEY, + NAME VARCHAR(100), + VERSION BIGINT +); +CREATE SEQUENCE "seq_with_version_seq" START WITH 1; diff --git a/spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository/JdbcRepositoryIdGenerationIntegrationTests-mariadb.sql b/spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository/JdbcRepositoryIdGenerationIntegrationTests-mariadb.sql index d85b1c8f1f..ac0d9c6bed 100644 --- a/spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository/JdbcRepositoryIdGenerationIntegrationTests-mariadb.sql +++ b/spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository/JdbcRepositoryIdGenerationIntegrationTests-mariadb.sql @@ -1,9 +1,40 @@ -CREATE TABLE ReadOnlyIdEntity (ID BIGINT AUTO_INCREMENT PRIMARY KEY, NAME VARCHAR(100)); -CREATE TABLE PrimitiveIdEntity (ID BIGINT AUTO_INCREMENT PRIMARY KEY, NAME VARCHAR(100)); -CREATE TABLE ImmutableWithManualIdentity (ID BIGINT PRIMARY KEY, NAME VARCHAR(100)); -CREATE TABLE SimpleSeq (ID BIGINT NOT NULL PRIMARY KEY, NAME VARCHAR(100)); +CREATE TABLE ReadOnlyIdEntity +( + ID BIGINT AUTO_INCREMENT PRIMARY KEY, + NAME VARCHAR(100) +); +CREATE TABLE PrimitiveIdEntity +( + ID BIGINT AUTO_INCREMENT PRIMARY KEY, + NAME VARCHAR(100) +); +CREATE TABLE ImmutableWithManualIdentity +( + ID BIGINT PRIMARY KEY, + NAME VARCHAR(100) +); +CREATE TABLE SimpleSeq +( + ID BIGINT NOT NULL PRIMARY KEY, + NAME VARCHAR(100) +); CREATE SEQUENCE simple_seq_seq START WITH 1; -CREATE TABLE PersistableSeq (ID BIGINT NOT NULL PRIMARY KEY, NAME VARCHAR(100)); +CREATE TABLE PersistableSeq +( + ID BIGINT NOT NULL PRIMARY KEY, + NAME VARCHAR(100) +); CREATE SEQUENCE persistable_seq_seq START WITH 1; -CREATE TABLE PrimitiveIdSeq (ID BIGINT NOT NULL PRIMARY KEY, NAME VARCHAR(100)); +CREATE TABLE PrimitiveIdSeq +( + ID BIGINT NOT NULL PRIMARY KEY, + NAME VARCHAR(100) +); CREATE SEQUENCE primitive_seq_seq START WITH 1; +CREATE TABLE IdSeqWithVersion +( + ID BIGINT NOT NULL PRIMARY KEY, + NAME VARCHAR(100), + VERSION BIGINT +); +CREATE SEQUENCE seq_with_version_seq START WITH 1; diff --git a/spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository/JdbcRepositoryIdGenerationIntegrationTests-mssql.sql b/spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository/JdbcRepositoryIdGenerationIntegrationTests-mssql.sql index bf06c52590..9921678f8b 100644 --- a/spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository/JdbcRepositoryIdGenerationIntegrationTests-mssql.sql +++ b/spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository/JdbcRepositoryIdGenerationIntegrationTests-mssql.sql @@ -9,13 +9,48 @@ DROP SEQUENCE IF EXISTS persistable_seq_seq; DROP TABLE IF EXISTS PrimitiveIdSeq; DROP SEQUENCE IF EXISTS primitive_seq_seq; -CREATE TABLE ReadOnlyIdEntity (ID BIGINT IDENTITY PRIMARY KEY, NAME VARCHAR(100)); -CREATE TABLE PrimitiveIdEntity (ID BIGINT IDENTITY PRIMARY KEY, NAME VARCHAR(100)); -CREATE TABLE ImmutableWithManualIdentity (ID BIGINT PRIMARY KEY, NAME VARCHAR(100)); -CREATE TABLE EntityWithSeq (ID BIGINT NOT NULL PRIMARY KEY, NAME VARCHAR(100)); -CREATE TABLE SimpleSeq (ID BIGINT NOT NULL PRIMARY KEY, NAME VARCHAR(100)); +CREATE TABLE ReadOnlyIdEntity +( + ID BIGINT IDENTITY PRIMARY KEY, + NAME VARCHAR(100) +); +CREATE TABLE PrimitiveIdEntity +( + ID BIGINT IDENTITY PRIMARY KEY, + NAME VARCHAR(100) +); +CREATE TABLE ImmutableWithManualIdentity +( + ID BIGINT PRIMARY KEY, + NAME VARCHAR(100) +); +CREATE TABLE EntityWithSeq +( + ID BIGINT NOT NULL PRIMARY KEY, + NAME VARCHAR(100) +); +CREATE TABLE SimpleSeq +( + ID BIGINT NOT NULL PRIMARY KEY, + NAME VARCHAR(100) +); CREATE SEQUENCE simple_seq_seq START WITH 1; -CREATE TABLE PersistableSeq (ID BIGINT NOT NULL PRIMARY KEY, NAME VARCHAR(100)); +CREATE TABLE PersistableSeq +( + ID BIGINT NOT NULL PRIMARY KEY, + NAME VARCHAR(100) +); CREATE SEQUENCE persistable_seq_seq START WITH 1; -CREATE TABLE PrimitiveIdSeq (ID BIGINT NOT NULL PRIMARY KEY, NAME VARCHAR(100)); +CREATE TABLE PrimitiveIdSeq +( + ID BIGINT NOT NULL PRIMARY KEY, + NAME VARCHAR(100) +); CREATE SEQUENCE primitive_seq_seq START WITH 1; +CREATE TABLE IdSeqWithVersion +( + ID BIGINT NOT NULL PRIMARY KEY, + NAME VARCHAR(100), + VERSION BIGINT +); +CREATE SEQUENCE seq_with_version_seq START WITH 1; diff --git a/spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository/JdbcRepositoryIdGenerationIntegrationTests-oracle.sql b/spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository/JdbcRepositoryIdGenerationIntegrationTests-oracle.sql index 8974a0dc7d..43433139d0 100644 --- a/spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository/JdbcRepositoryIdGenerationIntegrationTests-oracle.sql +++ b/spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository/JdbcRepositoryIdGenerationIntegrationTests-oracle.sql @@ -8,6 +8,8 @@ DROP TABLE PersistableSeq; DROP SEQUENCE persistable_seq_seq; DROP TABLE PrimitiveIdSeq; DROP SEQUENCE "primitive_seq_seq"; +DROP TABLE IdSeqWithVersion; +DROP SEQUENCE "seq_with_version_seq"; CREATE TABLE ReadOnlyIdEntity ( ID NUMBER GENERATED by default on null as IDENTITY PRIMARY KEY, @@ -44,3 +46,11 @@ CREATE TABLE PrimitiveIdSeq ( ); CREATE SEQUENCE "primitive_seq_seq" START WITH 1; + +CREATE TABLE IdSeqWithVersion ( + ID NUMBER PRIMARY KEY, + NAME VARCHAR2(100), + VERSION NUMBER +); + +CREATE SEQUENCE "seq_with_version_seq" START WITH 1; diff --git a/spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository/JdbcRepositoryIdGenerationIntegrationTests-postgres.sql b/spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository/JdbcRepositoryIdGenerationIntegrationTests-postgres.sql index 8f79fc83e6..7f1ee70ae1 100644 --- a/spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository/JdbcRepositoryIdGenerationIntegrationTests-postgres.sql +++ b/spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository/JdbcRepositoryIdGenerationIntegrationTests-postgres.sql @@ -5,12 +5,43 @@ DROP TABLE EntityWithSeq; DROP TABLE PersistableEntityWithSeq; DROP TABLE PrimitiveIdEntityWithSeq; -CREATE TABLE ReadOnlyIdEntity (ID SERIAL PRIMARY KEY, NAME VARCHAR(100)); -CREATE TABLE PrimitiveIdEntity (ID SERIAL PRIMARY KEY, NAME VARCHAR(100)); -CREATE TABLE ImmutableWithManualIdentity (ID BIGINT PRIMARY KEY, NAME VARCHAR(100)); -CREATE TABLE SimpleSeq (ID BIGINT NOT NULL PRIMARY KEY, NAME VARCHAR(100)); +CREATE TABLE ReadOnlyIdEntity +( + ID SERIAL PRIMARY KEY, + NAME VARCHAR(100) +); +CREATE TABLE PrimitiveIdEntity +( + ID SERIAL PRIMARY KEY, + NAME VARCHAR(100) +); +CREATE TABLE ImmutableWithManualIdentity +( + ID BIGINT PRIMARY KEY, + NAME VARCHAR(100) +); +CREATE TABLE SimpleSeq +( + ID BIGINT NOT NULL PRIMARY KEY, + NAME VARCHAR(100) +); CREATE SEQUENCE simple_seq_seq START WITH 1; -CREATE TABLE PersistableSeq (ID BIGINT NOT NULL PRIMARY KEY, NAME VARCHAR(100)); +CREATE TABLE PersistableSeq +( + ID BIGINT NOT NULL PRIMARY KEY, + NAME VARCHAR(100) +); CREATE SEQUENCE persistable_seq_seq START WITH 1; -CREATE TABLE PrimitiveIdSeq (ID BIGINT NOT NULL PRIMARY KEY, NAME VARCHAR(100)); -CREATE SEQUENCE primitive_seq_seq START WITH 1; \ No newline at end of file +CREATE TABLE PrimitiveIdSeq +( + ID BIGINT NOT NULL PRIMARY KEY, + NAME VARCHAR(100) +); +CREATE SEQUENCE primitive_seq_seq START WITH 1; +CREATE TABLE IdSeqWithVersion +( + ID BIGINT NOT NULL PRIMARY KEY, + NAME VARCHAR(100), + VERSION BIGINT +); +CREATE SEQUENCE seq_with_version_seq START WITH 1; \ No newline at end of file