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 75fdc528..95cc6dac 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 @@ -38,15 +38,17 @@ import org.springframework.data.domain.Persistable; import org.springframework.data.jdbc.core.convert.IdGeneratingEntityCallback; import org.springframework.data.jdbc.repository.config.EnableJdbcRepositories; import org.springframework.data.jdbc.repository.support.SimpleJdbcRepository; +import org.springframework.data.jdbc.testing.EnabledOnFeature; import org.springframework.data.jdbc.testing.IntegrationTest; import org.springframework.data.jdbc.testing.TestConfiguration; +import org.springframework.data.jdbc.testing.TestDatabaseFeatures; import org.springframework.data.relational.core.conversion.MutableAggregateChange; import org.springframework.data.relational.core.mapping.NamingStrategy; import org.springframework.data.relational.core.mapping.Sequence; import org.springframework.data.relational.core.mapping.event.BeforeConvertCallback; import org.springframework.data.repository.CrudRepository; import org.springframework.data.repository.ListCrudRepository; -import org.springframework.test.context.jdbc.Sql; +import org.springframework.jdbc.core.namedparam.NamedParameterJdbcOperations; /** * Testing special cases for id generation with {@link SimpleJdbcRepository}. @@ -59,6 +61,7 @@ import org.springframework.test.context.jdbc.Sql; @IntegrationTest class JdbcRepositoryIdGenerationIntegrationTests { + @Autowired NamedParameterJdbcOperations operations; @Autowired ReadOnlyIdEntityRepository readOnlyIdRepository; @Autowired PrimitiveIdEntityRepository primitiveIdRepository; @Autowired ImmutableWithManualIdEntityRepository immutableWithManualIdEntityRepository; @@ -123,9 +126,11 @@ class JdbcRepositoryIdGenerationIntegrationTests { } @Test // DATAJDBC-2003 - @Sql(statements = "INSERT INTO SimpleSeq(id, name) VALUES(1, 'initial value');") + @EnabledOnFeature(TestDatabaseFeatures.Feature.SUPPORTS_SEQUENCES) void testUpdateAggregateWithSequence() { + operations.getJdbcOperations().update("INSERT INTO SimpleSeq(id, name) VALUES(1, 'initial value')"); + SimpleSeq entity = new SimpleSeq(); entity.id = 1L; entity.name = "New name"; @@ -137,8 +142,8 @@ class JdbcRepositoryIdGenerationIntegrationTests { assertThat(afterCallback.join().id).isEqualTo(1L); } - @Test - // DATAJDBC-2003 + @Test // DATAJDBC-2003 + @EnabledOnFeature(TestDatabaseFeatures.Feature.SUPPORTS_SEQUENCES) void testInsertPersistableAggregateWithSequenceClientIdIsFavored() { long initialId = 1L; @@ -153,6 +158,7 @@ class JdbcRepositoryIdGenerationIntegrationTests { } @Test // DATAJDBC-2003 + @EnabledOnFeature(TestDatabaseFeatures.Feature.SUPPORTS_SEQUENCES) void testInsertAggregateWithSequenceAndUnsetPrimitiveId() { PrimitiveIdSeq entity = new PrimitiveIdSeq(); 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 a8a30edc..2b771677 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 @@ -12,4 +12,4 @@ CREATE SEQUENCE simple_seq_seq START WITH 1; 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; +CREATE SEQUENCE "primitive_seq_seq" START WITH 1; diff --git a/spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository/JdbcRepositoryIdGenerationIntegrationTests-mysql.sql b/spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository/JdbcRepositoryIdGenerationIntegrationTests-mysql.sql index d85b1c8f..7ad9775e 100644 --- a/spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository/JdbcRepositoryIdGenerationIntegrationTests-mysql.sql +++ b/spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository/JdbcRepositoryIdGenerationIntegrationTests-mysql.sql @@ -1,9 +1,3 @@ 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 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; 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 524074f3..3a041688 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 @@ -36,4 +36,4 @@ CREATE TABLE PrimitiveIdSeq ( NAME VARCHAR2(100) ); -CREATE SEQUENCE primitive_seq_seq START WITH 1; +CREATE SEQUENCE "primitive_seq_seq" START WITH 1;