Browse Source

DATAJDBC-257 - Adds DB2 support.

Db2Dialect added in order to support DB2.
Added test configuration files.
Adapted some tests to make them properly work with DB2
QueryAnnotationIntegrationTests converted into an Hsqldb only test since it is next to impossible to make it work across databases since it heavily depends on database and driver specifics.

Removed license acceptance file from the repository in order to not accept a license in the name of someone forking the repository.
For the CI build an appropriate file gets created on the fly.

Original pull request: #213.
pull/216/head
Jens Schauder 6 years ago committed by Mark Paluch
parent
commit
4bf2b8d0a8
No known key found for this signature in database
GPG Key ID: 51A00FA751B91849
  1. 5
      Jenkinsfile
  2. 6
      accept-third-party-license.sh
  3. 19
      pom.xml
  4. 12
      spring-data-jdbc/pom.xml
  5. 5
      spring-data-jdbc/src/main/java/org/springframework/data/jdbc/repository/config/DialectResolver.java
  6. 4
      spring-data-jdbc/src/test/java/org/springframework/data/jdbc/core/JdbcAggregateTemplateIntegrationTests.java
  7. 67
      spring-data-jdbc/src/test/java/org/springframework/data/jdbc/repository/query/QueryAnnotationHsqlIntegrationTests.java
  8. 59
      spring-data-jdbc/src/test/java/org/springframework/data/jdbc/testing/Db2DataSourceConfiguration.java
  9. 1
      spring-data-jdbc/src/test/resources/container-license-acceptance.txt
  10. 307
      spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.core/JdbcAggregateTemplateIntegrationTests-db2.sql
  11. 3
      spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository.config/EnableJdbcRepositoriesIntegrationTests-db2.sql
  12. 0
      spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository.query/QueryAnnotationHsqlIntegrationTests-hsql.sql
  13. 1
      spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository.query/QueryAnnotationIntegrationTests-hsql.sql
  14. 1
      spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository.query/QueryAnnotationIntegrationTests-mariadb.sql
  15. 1
      spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository.query/QueryAnnotationIntegrationTests-mysql.sql
  16. 2
      spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository.query/QueryAnnotationIntegrationTests-postgres.sql
  17. 3
      spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository/JdbcRepositoryCustomConversionIntegrationTests-db2.sql
  18. 2
      spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository/JdbcRepositoryEmbeddedImmutableIntegrationTests-db2.sql
  19. 2
      spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository/JdbcRepositoryEmbeddedIntegrationTests-db2.sql
  20. 5
      spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository/JdbcRepositoryEmbeddedNotInAggregateRootIntegrationTests-db2.sql
  21. 16
      spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository/JdbcRepositoryEmbeddedWithCollectionIntegrationTests-db2.sql
  22. 14
      spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository/JdbcRepositoryEmbeddedWithReferenceIntegrationTests-db2.sql
  23. 7
      spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository/JdbcRepositoryIdGenerationIntegrationTests-db2.sql
  24. 3
      spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository/JdbcRepositoryInsertExistingIntegrationTests-db2.sql
  25. 8
      spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository/JdbcRepositoryIntegrationTests-db2.sql
  26. 2
      spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository/JdbcRepositoryManipulateDbActionsIntegrationTests-h2.sql
  27. 2
      spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository/JdbcRepositoryManipulateDbActionsIntegrationTests-hsql.sql
  28. 2
      spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository/JdbcRepositoryManipulateDbActionsIntegrationTests-mariadb.sql
  29. 4
      spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository/JdbcRepositoryManipulateDbActionsIntegrationTests-mssql.sql
  30. 2
      spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository/JdbcRepositoryManipulateDbActionsIntegrationTests-mysql.sql
  31. 4
      spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository/JdbcRepositoryManipulateDbActionsIntegrationTests-postgres.sql
  32. 11
      spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository/JdbcRepositoryPropertyConversionIntegrationTests-db2.sql
  33. 7
      spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository/JdbcRepositoryResultSetExtractorIntegrationTests-db2.sql
  34. 5
      spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository/JdbcRepositoryWithCollectionsIntegrationTests-db2.sql
  35. 5
      spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository/JdbcRepositoryWithListsIntegrationTests-db2.sql
  36. 9
      spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository/JdbcRepositoryWithMapsIntegrationTests-db2.sql
  37. 3
      spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository/StringBasedJdbcQueryMappingConfigurationIntegrationTests-db2.sql
  38. 3
      spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository/StringBasedJdbcQueryMappingConfigurationIntegrationTests-h2.sql
  39. 87
      spring-data-relational/src/main/java/org/springframework/data/relational/core/dialect/Db2Dialect.java

5
Jenkinsfile vendored

@ -29,6 +29,7 @@ pipeline { @@ -29,6 +29,7 @@ pipeline {
}
options { timeout(time: 30, unit: 'MINUTES') }
steps {
sh './accept-third-party-license.sh'
sh 'mkdir -p /tmp/jenkins-home'
sh 'chown -R 1001:1001 .'
sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -Pci,all-dbs clean dependency:list test -Dsort -U -B'
@ -55,6 +56,7 @@ pipeline { @@ -55,6 +56,7 @@ pipeline {
}
options { timeout(time: 30, unit: 'MINUTES') }
steps {
sh './accept-third-party-license.sh'
sh 'mkdir -p /tmp/jenkins-home'
sh 'chown -R 1001:1001 .'
sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -Pci,all-dbs,java11 clean dependency:list test -Dsort -U -B'
@ -73,7 +75,8 @@ pipeline { @@ -73,7 +75,8 @@ pipeline {
}
options { timeout(time: 30, unit: 'MINUTES') }
steps {
sh 'mkdir -p /tmp/jenkins-home'
sh './accept-third-party-license.sh'
sh 'mkdir -p /tmp/jenkins-home'
sh 'chown -R 1001:1001 .'
sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -Pci,all-dbs,java11 clean dependency:list test -Dsort -U -B'
sh 'chown -R 1001:1001 .'

6
accept-third-party-license.sh

@ -0,0 +1,6 @@ @@ -0,0 +1,6 @@
#!/bin/sh
{
echo "mcr.microsoft.com/mssql/server:2017-CU12"
echo "ibmcom/db2:11.5.0.0a"
} > spring-data-jdbc/src/test/resources/container-license-acceptance.txt

19
pom.xml

@ -25,6 +25,7 @@ @@ -25,6 +25,7 @@
<degraph-check.version>0.1.4</degraph-check.version>
<db2.version>11.5.0.0</db2.version>
<h2.version>1.4.200</h2.version>
<hsqldb.version>2.2.8</hsqldb.version>
<mssql.version>7.0.0.jre8</mssql.version>
@ -170,6 +171,24 @@ @@ -170,6 +171,24 @@
</systemPropertyVariables>
</configuration>
</execution>
<execution>
<id>db2-test</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<includes>
<include>**/*IntegrationTests.java</include>
</includes>
<excludes>
<exclude>**/*HsqlIntegrationTests.java</exclude>
</excludes>
<systemPropertyVariables>
<spring.profiles.active>db2</spring.profiles.active>
</systemPropertyVariables>
</configuration>
</execution>
<!--<execution>-->
<!--<id>mssql-test</id>-->
<!--<phase>test</phase>-->

12
spring-data-jdbc/pom.xml

@ -186,6 +186,12 @@ @@ -186,6 +186,12 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.ibm.db2</groupId>
<artifactId>jcc</artifactId>
<version>11.1.4.4</version>
</dependency>
<dependency>
<groupId>de.schauderhaft.degraph</groupId>
<artifactId>degraph-check</artifactId>
@ -223,6 +229,12 @@ @@ -223,6 +229,12 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>db2</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>

5
spring-data-jdbc/src/main/java/org/springframework/data/jdbc/repository/config/DialectResolver.java

@ -26,6 +26,7 @@ import javax.sql.DataSource; @@ -26,6 +26,7 @@ import javax.sql.DataSource;
import org.springframework.core.io.support.SpringFactoriesLoader;
import org.springframework.dao.NonTransientDataAccessException;
import org.springframework.data.relational.core.dialect.Db2Dialect;
import org.springframework.data.relational.core.dialect.Dialect;
import org.springframework.data.relational.core.dialect.H2Dialect;
import org.springframework.data.relational.core.dialect.HsqlDbDialect;
@ -123,7 +124,9 @@ public class DialectResolver { @@ -123,7 +124,9 @@ public class DialectResolver {
if (name.contains("microsoft")) {
return SqlServerDialect.INSTANCE;
}
if (name.contains("db2")) {
return Db2Dialect.INSTANCE;
}
return null;
}

4
spring-data-jdbc/src/test/java/org/springframework/data/jdbc/core/JdbcAggregateTemplateIntegrationTests.java

@ -514,6 +514,7 @@ public class JdbcAggregateTemplateIntegrationTests { @@ -514,6 +514,7 @@ public class JdbcAggregateTemplateIntegrationTests {
assumeNot("mysql");
assumeNot("mariadb");
assumeNot("mssql");
assumeNot("db2");
ArrayOwner arrayOwner = new ArrayOwner();
arrayOwner.digits = new String[] { "one", "two", "three" };
@ -539,6 +540,7 @@ public class JdbcAggregateTemplateIntegrationTests { @@ -539,6 +540,7 @@ public class JdbcAggregateTemplateIntegrationTests {
assumeNot("mariadb");
assumeNot("mssql");
assumeNot("hsqldb");
assumeNot("db2");
ArrayOwner arrayOwner = new ArrayOwner();
arrayOwner.multidimensional = new String[][] { { "one-a", "two-a", "three-a" }, { "one-b", "two-b", "three-b" } };
@ -563,6 +565,7 @@ public class JdbcAggregateTemplateIntegrationTests { @@ -563,6 +565,7 @@ public class JdbcAggregateTemplateIntegrationTests {
assumeNot("mysql");
assumeNot("mariadb");
assumeNot("mssql");
assumeNot("db2");
ListOwner arrayOwner = new ListOwner();
arrayOwner.digits.addAll(Arrays.asList("one", "two", "three"));
@ -586,6 +589,7 @@ public class JdbcAggregateTemplateIntegrationTests { @@ -586,6 +589,7 @@ public class JdbcAggregateTemplateIntegrationTests {
assumeNot("mysql");
assumeNot("mariadb");
assumeNot("mssql");
assumeNot("db2");
SetOwner setOwner = new SetOwner();
setOwner.digits.addAll(Arrays.asList("one", "two", "three"));

67
spring-data-jdbc/src/test/java/org/springframework/data/jdbc/repository/query/QueryAnnotationIntegrationTests.java → spring-data-jdbc/src/test/java/org/springframework/data/jdbc/repository/query/QueryAnnotationHsqlIntegrationTests.java

@ -19,18 +19,16 @@ import static org.assertj.core.api.Assertions.*; @@ -19,18 +19,16 @@ import static org.assertj.core.api.Assertions.*;
import lombok.Value;
import java.sql.Timestamp;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;
import java.util.Optional;
import java.util.stream.Stream;
import org.junit.Assume;
import org.assertj.core.api.SoftAssertions;
import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@ -42,7 +40,7 @@ import org.springframework.data.jdbc.testing.TestConfiguration; @@ -42,7 +40,7 @@ import org.springframework.data.jdbc.testing.TestConfiguration;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.lang.Nullable;
import org.springframework.test.annotation.ProfileValueUtils;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.rules.SpringClassRule;
import org.springframework.test.context.junit4.rules.SpringMethodRule;
import org.springframework.transaction.annotation.Transactional;
@ -55,7 +53,8 @@ import org.springframework.transaction.annotation.Transactional; @@ -55,7 +53,8 @@ import org.springframework.transaction.annotation.Transactional;
* @author Mark Paluch
*/
@Transactional
public class QueryAnnotationIntegrationTests {
@ActiveProfiles("hsql")
public class QueryAnnotationHsqlIntegrationTests {
@Configuration
@Import(TestConfiguration.class)
@ -64,7 +63,7 @@ public class QueryAnnotationIntegrationTests { @@ -64,7 +63,7 @@ public class QueryAnnotationIntegrationTests {
@Bean
Class<?> testClass() {
return QueryAnnotationIntegrationTests.class;
return QueryAnnotationHsqlIntegrationTests.class;
}
}
@ -76,8 +75,6 @@ public class QueryAnnotationIntegrationTests { @@ -76,8 +75,6 @@ public class QueryAnnotationIntegrationTests {
@Test // DATAJDBC-164
public void executeCustomQueryWithoutParameter() {
assumeNot("mysql");
repository.save(dummyEntity("Example"));
repository.save(dummyEntity("example"));
repository.save(dummyEntity("EXAMPLE"));
@ -180,8 +177,6 @@ public class QueryAnnotationIntegrationTests { @@ -180,8 +177,6 @@ public class QueryAnnotationIntegrationTests {
@Test // DATAJDBC-175
public void executeCustomQueryWithReturnTypeIsNumber() {
assumeNot("mysql");
repository.save(dummyEntity("aaa"));
repository.save(dummyEntity("bbb"));
repository.save(dummyEntity("cac"));
@ -194,40 +189,29 @@ public class QueryAnnotationIntegrationTests { @@ -194,40 +189,29 @@ public class QueryAnnotationIntegrationTests {
@Test // DATAJDBC-175
public void executeCustomQueryWithReturnTypeIsBoolean() {
assumeNot("mysql");
repository.save(dummyEntity("aaa"));
repository.save(dummyEntity("bbb"));
repository.save(dummyEntity("cac"));
assertThat(repository.existsByNameContaining("a")).isTrue();
assertThat(repository.existsByNameContaining("d")).isFalse();
SoftAssertions.assertSoftly(softly -> {
softly.assertThat(repository.existsByNameContaining("a")).describedAs("entities with A in the name").isTrue();
softly.assertThat(repository.existsByNameContaining("d")).describedAs("entities with D in the name").isFalse();
});
}
@Test // DATAJDBC-175
public void executeCustomQueryWithReturnTypeIsDate() {
assumeNot("mysql");
// Since Timestamp extends Date the repository returns the Timestamp as it comes from the database.
// Trying to compare that to an actual Date results in non deterministic results, so we have to use an actual
// Timestamp.
Date now = new Timestamp(System.currentTimeMillis());
assertThat(repository.nowWithDate()).isAfterOrEqualsTo(now);
assertThat(repository.nowWithDate()).isInstanceOf(Date.class);
}
@Test // DATAJDBC-175
public void executeCustomQueryWithReturnTypeIsLocalDateTimeList() {
// mysql does not support plain VALUES(…)
assumeNot("mysql");
LocalDateTime preciseNow = LocalDateTime.now();
LocalDateTime truncatedNow = truncateSubmillis(preciseNow);
repository.nowWithLocalDateTimeList() //
.forEach(d -> assertThat(d).isAfterOrEqualTo(truncatedNow));
assertThat(repository.nowWithLocalDateTimeList()) //
.hasSize(2) //
.allSatisfy(d -> assertThat(d).isInstanceOf(LocalDateTime.class));
}
@Test // DATAJDBC-182
@ -270,19 +254,9 @@ public class QueryAnnotationIntegrationTests { @@ -270,19 +254,9 @@ public class QueryAnnotationIntegrationTests {
@Test // DATAJDBC-175
public void executeCustomQueryWithImmutableResultType() {
// mysql does not support plain VALUES(…)
assumeNot("mysql");
assertThat(repository.immutableTuple()).isEqualTo(new DummyEntityRepository.ImmutableTuple("one", "two", 3));
}
private static LocalDateTime truncateSubmillis(LocalDateTime now) {
int NANOS_IN_MILLIS = 1_000_000;
return now.withNano((now.getNano() / NANOS_IN_MILLIS) * 1_000_000);
}
private DummyEntity dummyEntity(String name) {
DummyEntity entity = new DummyEntity();
@ -290,13 +264,6 @@ public class QueryAnnotationIntegrationTests { @@ -290,13 +264,6 @@ public class QueryAnnotationIntegrationTests {
return entity;
}
private static void assumeNot(String dbProfileName) {
Assume.assumeTrue(
"true".equalsIgnoreCase(ProfileValueUtils.retrieveProfileValueSource(QueryAnnotationIntegrationTests.class)
.get("current.database.is.not." + dbProfileName)));
}
private static class DummyEntity {
@Id Long id;
@ -327,11 +294,11 @@ public class QueryAnnotationIntegrationTests { @@ -327,11 +294,11 @@ public class QueryAnnotationIntegrationTests {
Stream<DummyEntity> findAllWithReturnTypeIsStream();
// DATAJDBC-175
@Query("SELECT count(*) FROM DUMMY_ENTITY WHERE name like '%' || :name || '%'")
@Query("SELECT count(*) FROM DUMMY_ENTITY WHERE name like concat('%', :name, '%')")
int countByNameContaining(@Param("name") String name);
// DATAJDBC-175
@Query("SELECT count(*) FROM DUMMY_ENTITY WHERE name like '%' || :name || '%'")
@Query("SELECT case when count(*) > 0 THEN 'true' ELSE 'false' END FROM DUMMY_ENTITY WHERE name like '%' || :name || '%'")
boolean existsByNameContaining(@Param("name") String name);
// DATAJDBC-175
@ -358,7 +325,7 @@ public class QueryAnnotationIntegrationTests { @@ -358,7 +325,7 @@ public class QueryAnnotationIntegrationTests {
void insert(@Param("name") String name);
// DATAJDBC-252
@Query("SELECT 'one' one, 'two' two, 3 three FROM (VALUES (0))")
@Query("SELECT 'one' one, 'two' two, 3 three FROM (VALUES (0)) as tableName")
ImmutableTuple immutableTuple();
@Value

59
spring-data-jdbc/src/test/java/org/springframework/data/jdbc/testing/Db2DataSourceConfiguration.java

@ -0,0 +1,59 @@ @@ -0,0 +1,59 @@
/*
* Copyright 2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.jdbc.testing;
import javax.sql.DataSource;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.jdbc.datasource.DriverManagerDataSource;
import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator;
import org.testcontainers.containers.Db2Container;
/**
* {@link DataSource} setup for DB2.
*
* @author Jens Schauder
* @author Oliver Gierke
*/
@Configuration
@Profile("db2")
class Db2DataSourceConfiguration extends DataSourceConfiguration {
private static final Db2Container DB_2_CONTAINER = new Db2Container();
static {
DB_2_CONTAINER.start();
}
/*
* (non-Javadoc)
* @see org.springframework.data.jdbc.testing.DataSourceConfiguration#createDataSource()
*/
@Override
protected DataSource createDataSource() {
DriverManagerDataSource dataSource = new DriverManagerDataSource(DB_2_CONTAINER.getJdbcUrl(),
DB_2_CONTAINER.getUsername(), DB_2_CONTAINER.getPassword());
return dataSource;
}
@Override
protected void customizePopulator(ResourceDatabasePopulator populator) {
populator.setIgnoreFailedDrops(true);
}
}

1
spring-data-jdbc/src/test/resources/container-license-acceptance.txt

@ -1 +0,0 @@ @@ -1 +0,0 @@
mcr.microsoft.com/mssql/server:2017-CU12

307
spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.core/JdbcAggregateTemplateIntegrationTests-db2.sql

@ -0,0 +1,307 @@ @@ -0,0 +1,307 @@
CREATE TABLE LEGO_SET
(
"id1" BIGINT GENERATED BY DEFAULT AS IDENTITY (START WITH 1) PRIMARY KEY,
NAME VARCHAR(30)
);
CREATE TABLE MANUAL
(
"id2" BIGINT GENERATED BY DEFAULT AS IDENTITY (START WITH 1) PRIMARY KEY,
LEGO_SET BIGINT,
"alternative" BIGINT,
CONTENT VARCHAR(2000)
);
ALTER TABLE MANUAL
ADD FOREIGN KEY (LEGO_SET)
REFERENCES LEGO_SET ("id1");
CREATE TABLE ONE_TO_ONE_PARENT
(
"id3" BIGINT GENERATED BY DEFAULT AS IDENTITY (START WITH 1) PRIMARY KEY,
content VARCHAR(30)
);
CREATE TABLE Child_No_Id
(
ONE_TO_ONE_PARENT INTEGER NOT NULL PRIMARY KEY,
content VARCHAR(30)
);
CREATE TABLE LIST_PARENT
(
"id4" BIGINT GENERATED BY DEFAULT AS IDENTITY ( START WITH 1 ) PRIMARY KEY,
NAME VARCHAR(100)
);
CREATE TABLE ELEMENT_NO_ID
(
CONTENT VARCHAR(100),
LIST_PARENT_KEY BIGINT,
LIST_PARENT BIGINT
);
ALTER TABLE ELEMENT_NO_ID
ADD FOREIGN KEY (LIST_PARENT)
REFERENCES LIST_PARENT ("id4");
--
-- CREATE TABLE ARRAY_OWNER
-- (
-- ID BIGINT GENERATED BY DEFAULT AS IDENTITY (START WITH 1) PRIMARY KEY,
-- DIGITS VARCHAR(20) ARRAY[10] NOT NULL,
-- MULTIDIMENSIONAL VARCHAR(20) ARRAY[10] NULL
-- );
CREATE TABLE BYTE_ARRAY_OWNER
(
ID BIGINT GENERATED BY DEFAULT AS IDENTITY (START WITH 1) PRIMARY KEY,
BINARY_DATA VARBINARY(20) NOT NULL
);
CREATE TABLE CHAIN4
(
FOUR BIGINT GENERATED BY DEFAULT AS IDENTITY (START WITH 40) PRIMARY KEY,
FOUR_VALUE VARCHAR(20)
);
CREATE TABLE CHAIN3
(
THREE BIGINT GENERATED BY DEFAULT AS IDENTITY (START WITH 30) PRIMARY KEY,
THREE_VALUE VARCHAR(20),
CHAIN4 BIGINT,
FOREIGN KEY (CHAIN4) REFERENCES CHAIN4 (FOUR)
);
CREATE TABLE CHAIN2
(
TWO BIGINT GENERATED BY DEFAULT AS IDENTITY (START WITH 20) PRIMARY KEY,
TWO_VALUE VARCHAR(20),
CHAIN3 BIGINT,
FOREIGN KEY (CHAIN3) REFERENCES CHAIN3 (THREE)
);
CREATE TABLE CHAIN1
(
ONE BIGINT GENERATED BY DEFAULT AS IDENTITY (START WITH 10) PRIMARY KEY,
ONE_VALUE VARCHAR(20),
CHAIN2 BIGINT,
FOREIGN KEY (CHAIN2) REFERENCES CHAIN2 (TWO)
);
CREATE TABLE CHAIN0
(
ZERO BIGINT GENERATED BY DEFAULT AS IDENTITY (START WITH 0) PRIMARY KEY,
ZERO_VALUE VARCHAR(20),
CHAIN1 BIGINT,
FOREIGN KEY (CHAIN1) REFERENCES CHAIN1 (ONE)
);
CREATE TABLE NO_ID_CHAIN4
(
FOUR BIGINT GENERATED BY DEFAULT AS IDENTITY (START WITH 40) PRIMARY KEY,
FOUR_VALUE VARCHAR(20)
);
CREATE TABLE NO_ID_CHAIN3
(
THREE_VALUE VARCHAR(20),
NO_ID_CHAIN4 BIGINT,
FOREIGN KEY (NO_ID_CHAIN4) REFERENCES NO_ID_CHAIN4 (FOUR)
);
CREATE TABLE NO_ID_CHAIN2
(
TWO_VALUE VARCHAR(20),
NO_ID_CHAIN4 BIGINT,
FOREIGN KEY (NO_ID_CHAIN4) REFERENCES NO_ID_CHAIN4 (FOUR)
);
CREATE TABLE NO_ID_CHAIN1
(
ONE_VALUE VARCHAR(20),
NO_ID_CHAIN4 BIGINT,
FOREIGN KEY (NO_ID_CHAIN4) REFERENCES NO_ID_CHAIN4 (FOUR)
);
CREATE TABLE NO_ID_CHAIN0
(
ZERO_VALUE VARCHAR(20),
NO_ID_CHAIN4 BIGINT,
FOREIGN KEY (NO_ID_CHAIN4) REFERENCES NO_ID_CHAIN4 (FOUR)
);
CREATE TABLE NO_ID_LIST_CHAIN4
(
FOUR BIGINT GENERATED BY DEFAULT AS IDENTITY (START WITH 40) PRIMARY KEY,
FOUR_VALUE VARCHAR(20)
);
CREATE TABLE NO_ID_LIST_CHAIN3
(
THREE_VALUE VARCHAR(20),
NO_ID_LIST_CHAIN4 BIGINT NOT NULL,
NO_ID_LIST_CHAIN4_KEY BIGINT NOT NULL,
PRIMARY KEY (NO_ID_LIST_CHAIN4,
NO_ID_LIST_CHAIN4_KEY),
FOREIGN KEY (NO_ID_LIST_CHAIN4) REFERENCES NO_ID_LIST_CHAIN4 (FOUR)
);
CREATE TABLE NO_ID_LIST_CHAIN2
(
TWO_VALUE VARCHAR(20),
NO_ID_LIST_CHAIN4 BIGINT NOT NULL,
NO_ID_LIST_CHAIN4_KEY BIGINT NOT NULL,
NO_ID_LIST_CHAIN3_KEY BIGINT NOT NULL,
PRIMARY KEY (NO_ID_LIST_CHAIN4,
NO_ID_LIST_CHAIN4_KEY,
NO_ID_LIST_CHAIN3_KEY),
FOREIGN KEY (
NO_ID_LIST_CHAIN4,
NO_ID_LIST_CHAIN4_KEY
) REFERENCES NO_ID_LIST_CHAIN3 (
NO_ID_LIST_CHAIN4,
NO_ID_LIST_CHAIN4_KEY
)
);
CREATE TABLE NO_ID_LIST_CHAIN1
(
ONE_VALUE VARCHAR(20),
NO_ID_LIST_CHAIN4 BIGINT NOT NULL,
NO_ID_LIST_CHAIN4_KEY BIGINT NOT NULL,
NO_ID_LIST_CHAIN3_KEY BIGINT NOT NULL,
NO_ID_LIST_CHAIN2_KEY BIGINT NOT NULL,
PRIMARY KEY (NO_ID_LIST_CHAIN4,
NO_ID_LIST_CHAIN4_KEY,
NO_ID_LIST_CHAIN3_KEY,
NO_ID_LIST_CHAIN2_KEY),
FOREIGN KEY (
NO_ID_LIST_CHAIN4,
NO_ID_LIST_CHAIN4_KEY,
NO_ID_LIST_CHAIN3_KEY
) REFERENCES NO_ID_LIST_CHAIN2 (
NO_ID_LIST_CHAIN4,
NO_ID_LIST_CHAIN4_KEY,
NO_ID_LIST_CHAIN3_KEY
)
);
CREATE TABLE NO_ID_LIST_CHAIN0
(
ZERO_VALUE VARCHAR(20),
NO_ID_LIST_CHAIN4 BIGINT NOT NULL,
NO_ID_LIST_CHAIN4_KEY BIGINT NOT NULL,
NO_ID_LIST_CHAIN3_KEY BIGINT NOT NULL,
NO_ID_LIST_CHAIN2_KEY BIGINT NOT NULL,
NO_ID_LIST_CHAIN1_KEY BIGINT NOT NULL,
PRIMARY KEY (NO_ID_LIST_CHAIN4,
NO_ID_LIST_CHAIN4_KEY,
NO_ID_LIST_CHAIN3_KEY,
NO_ID_LIST_CHAIN2_KEY,
NO_ID_LIST_CHAIN1_KEY),
FOREIGN KEY (
NO_ID_LIST_CHAIN4,
NO_ID_LIST_CHAIN4_KEY,
NO_ID_LIST_CHAIN3_KEY,
NO_ID_LIST_CHAIN2_KEY
) REFERENCES NO_ID_LIST_CHAIN1 (
NO_ID_LIST_CHAIN4,
NO_ID_LIST_CHAIN4_KEY,
NO_ID_LIST_CHAIN3_KEY,
NO_ID_LIST_CHAIN2_KEY
)
);
CREATE TABLE NO_ID_MAP_CHAIN4
(
FOUR BIGINT GENERATED BY DEFAULT AS IDENTITY (START WITH 40) PRIMARY KEY,
FOUR_VALUE VARCHAR(20)
);
CREATE TABLE NO_ID_MAP_CHAIN3
(
THREE_VALUE VARCHAR(20),
NO_ID_MAP_CHAIN4 BIGINT NOT NULL,
NO_ID_MAP_CHAIN4_KEY VARCHAR(20) NOT NULL,
PRIMARY KEY (NO_ID_MAP_CHAIN4,
NO_ID_MAP_CHAIN4_KEY),
FOREIGN KEY (NO_ID_MAP_CHAIN4) REFERENCES NO_ID_MAP_CHAIN4 (FOUR)
);
CREATE TABLE NO_ID_MAP_CHAIN2
(
TWO_VALUE VARCHAR(20),
NO_ID_MAP_CHAIN4 BIGINT NOT NULL,
NO_ID_MAP_CHAIN4_KEY VARCHAR(20) NOT NULL,
NO_ID_MAP_CHAIN3_KEY VARCHAR(20) NOT NULL,
PRIMARY KEY (NO_ID_MAP_CHAIN4,
NO_ID_MAP_CHAIN4_KEY,
NO_ID_MAP_CHAIN3_KEY),
FOREIGN KEY (
NO_ID_MAP_CHAIN4,
NO_ID_MAP_CHAIN4_KEY
) REFERENCES NO_ID_MAP_CHAIN3 (
NO_ID_MAP_CHAIN4,
NO_ID_MAP_CHAIN4_KEY
)
);
CREATE TABLE NO_ID_MAP_CHAIN1
(
ONE_VALUE VARCHAR(20),
NO_ID_MAP_CHAIN4 BIGINT NOT NULL,
NO_ID_MAP_CHAIN4_KEY VARCHAR(20) NOT NULL,
NO_ID_MAP_CHAIN3_KEY VARCHAR(20) NOT NULL,
NO_ID_MAP_CHAIN2_KEY VARCHAR(20) NOT NULL,
PRIMARY KEY (NO_ID_MAP_CHAIN4,
NO_ID_MAP_CHAIN4_KEY,
NO_ID_MAP_CHAIN3_KEY,
NO_ID_MAP_CHAIN2_KEY),
FOREIGN KEY (
NO_ID_MAP_CHAIN4,
NO_ID_MAP_CHAIN4_KEY,
NO_ID_MAP_CHAIN3_KEY
) REFERENCES NO_ID_MAP_CHAIN2 (
NO_ID_MAP_CHAIN4,
NO_ID_MAP_CHAIN4_KEY,
NO_ID_MAP_CHAIN3_KEY
)
);
CREATE TABLE NO_ID_MAP_CHAIN0
(
ZERO_VALUE VARCHAR(20),
NO_ID_MAP_CHAIN4 BIGINT NOT NULL,
NO_ID_MAP_CHAIN4_KEY VARCHAR(20) NOT NULL,
NO_ID_MAP_CHAIN3_KEY VARCHAR(20) NOT NULL,
NO_ID_MAP_CHAIN2_KEY VARCHAR(20) NOT NULL,
NO_ID_MAP_CHAIN1_KEY VARCHAR(20) NOT NULL,
PRIMARY KEY (NO_ID_MAP_CHAIN4,
NO_ID_MAP_CHAIN4_KEY,
NO_ID_MAP_CHAIN3_KEY,
NO_ID_MAP_CHAIN2_KEY,
NO_ID_MAP_CHAIN1_KEY),
FOREIGN KEY (
NO_ID_MAP_CHAIN4,
NO_ID_MAP_CHAIN4_KEY,
NO_ID_MAP_CHAIN3_KEY,
NO_ID_MAP_CHAIN2_KEY
) REFERENCES NO_ID_MAP_CHAIN1 (
NO_ID_MAP_CHAIN4,
NO_ID_MAP_CHAIN4_KEY,
NO_ID_MAP_CHAIN3_KEY,
NO_ID_MAP_CHAIN2_KEY
)
);
CREATE TABLE WITH_READ_ONLY (
ID BIGINT GENERATED BY DEFAULT AS IDENTITY (START WITH 40) PRIMARY KEY,
NAME VARCHAR(200),
READ_ONLY VARCHAR(200) DEFAULT 'from-db'
);
CREATE TABLE VERSIONED_AGGREGATE
(
ID BIGINT GENERATED BY DEFAULT AS IDENTITY (START WITH 1) PRIMARY KEY,
VERSION BIGINT
);

3
spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository.config/EnableJdbcRepositoriesIntegrationTests-db2.sql

@ -0,0 +1,3 @@ @@ -0,0 +1,3 @@
DROP TABLE Dummy_entity;
CREATE TABLE Dummy_Entity ( id BIGINT GENERATED BY DEFAULT AS IDENTITY ( START WITH 1 ) PRIMARY KEY)

0
spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository.query/QueryAnnotationIntegrationTests-h2.sql → spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository.query/QueryAnnotationHsqlIntegrationTests-hsql.sql

1
spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository.query/QueryAnnotationIntegrationTests-hsql.sql

@ -1 +0,0 @@ @@ -1 +0,0 @@
CREATE TABLE dummy_entity ( id BIGINT GENERATED BY DEFAULT AS IDENTITY ( START WITH 1 ) PRIMARY KEY, NAME VARCHAR(100))

1
spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository.query/QueryAnnotationIntegrationTests-mariadb.sql

@ -1 +0,0 @@ @@ -1 +0,0 @@
CREATE TABLE dummy_entity ( id BIGINT AUTO_INCREMENT PRIMARY KEY, NAME VARCHAR(100))

1
spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository.query/QueryAnnotationIntegrationTests-mysql.sql

@ -1 +0,0 @@ @@ -1 +0,0 @@
CREATE TABLE dummy_entity ( id BIGINT AUTO_INCREMENT PRIMARY KEY, NAME VARCHAR(100))

2
spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository.query/QueryAnnotationIntegrationTests-postgres.sql

@ -1,2 +0,0 @@ @@ -1,2 +0,0 @@
DROP TABLE IF EXISTS dummy_entity;
CREATE TABLE dummy_entity ( id SERIAL PRIMARY KEY, NAME VARCHAR(100));

3
spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository/JdbcRepositoryCustomConversionIntegrationTests-db2.sql

@ -0,0 +1,3 @@ @@ -0,0 +1,3 @@
DROP TABLE ENTITY_WITH_STRINGY_BIG_DECIMAL;
CREATE TABLE ENTITY_WITH_STRINGY_BIG_DECIMAL ( id BIGINT GENERATED BY DEFAULT AS IDENTITY(START WITH 1) PRIMARY KEY, Stringy_number DECIMAL(20,10));

2
spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository/JdbcRepositoryEmbeddedImmutableIntegrationTests-db2.sql

@ -0,0 +1,2 @@ @@ -0,0 +1,2 @@
DROP TABLE dummy_entity;
CREATE TABLE dummy_entity ( id BIGINT GENERATED BY DEFAULT AS IDENTITY ( START WITH 1 ) PRIMARY KEY, PREFIX_ATTR1 BIGINT, PREFIX_ATTR2 VARCHAR(100))

2
spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository/JdbcRepositoryEmbeddedIntegrationTests-db2.sql

@ -0,0 +1,2 @@ @@ -0,0 +1,2 @@
DROP TABLE dummy_entity;
CREATE TABLE dummy_entity ( id BIGINT GENERATED BY DEFAULT AS IDENTITY ( START WITH 1 ) PRIMARY KEY, TEST VARCHAR(100), PREFIX2_ATTR BIGINT, PREFIX_TEST VARCHAR(100), PREFIX_PREFIX2_ATTR BIGINT);

5
spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository/JdbcRepositoryEmbeddedNotInAggregateRootIntegrationTests-db2.sql

@ -0,0 +1,5 @@ @@ -0,0 +1,5 @@
DROP TABLE dummy_entity;
DROP TABLE dummy_entity2;
CREATE TABLE dummy_entity ( id BIGINT GENERATED BY DEFAULT AS IDENTITY ( START WITH 1 ) PRIMARY KEY, TEST VARCHAR(100));
CREATE TABLE dummy_entity2 ( id BIGINT GENERATED BY DEFAULT AS IDENTITY ( START WITH 1 ) PRIMARY KEY, TEST VARCHAR(100), PREFIX_ATTR BIGINT)

16
spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository/JdbcRepositoryEmbeddedWithCollectionIntegrationTests-db2.sql

@ -0,0 +1,16 @@ @@ -0,0 +1,16 @@
DROP TABLE dummy_entity;
DROP TABLE dummy_entity2;
CREATE TABLE dummy_entity
(
id BIGINT GENERATED BY DEFAULT AS IDENTITY ( START WITH 1 ) PRIMARY KEY,
TEST VARCHAR(100),
PREFIX_TEST VARCHAR(100)
);
CREATE TABLE dummy_entity2
(
id BIGINT NOT NULL,
ORDER_KEY BIGINT NOT NULL,
TEST VARCHAR(100),
PRIMARY KEY (id, ORDER_KEY)
)

14
spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository/JdbcRepositoryEmbeddedWithReferenceIntegrationTests-db2.sql

@ -0,0 +1,14 @@ @@ -0,0 +1,14 @@
DROP TABLE dummy_entity;
DROP TABLE dummy_entity2;
CREATE TABLE dummy_entity
(
ID BIGINT GENERATED BY DEFAULT AS IDENTITY ( START WITH 1 ) PRIMARY KEY,
TEST VARCHAR(100),
PREFIX_TEST VARCHAR(100)
);
CREATE TABLE dummy_entity2
(
ID BIGINT,
TEST VARCHAR(100)
)

7
spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository/JdbcRepositoryIdGenerationIntegrationTests-db2.sql

@ -0,0 +1,7 @@ @@ -0,0 +1,7 @@
DROP TABLE ReadOnlyIdEntity;
DROP TABLE PrimitiveIdEntity;
DROP TABLE ImmutableWithManualIdentity;
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 NOT NULL PRIMARY KEY, NAME VARCHAR(100));

3
spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository/JdbcRepositoryInsertExistingIntegrationTests-db2.sql

@ -0,0 +1,3 @@ @@ -0,0 +1,3 @@
DROP TABLE dummy_entity;
CREATE TABLE dummy_entity ( id_Prop BIGINT PRIMARY KEY, NAME VARCHAR(100))

8
spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository/JdbcRepositoryIntegrationTests-db2.sql

@ -0,0 +1,8 @@ @@ -0,0 +1,8 @@
DROP TABLE dummy_entity;
CREATE TABLE dummy_entity
(
id_Prop BIGINT GENERATED BY DEFAULT AS IDENTITY ( START WITH 1 ) PRIMARY KEY,
NAME VARCHAR(100),
POINT_IN_TIME TIMESTAMP
);

2
spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository/JdbcRepositoryManipulateDbActionsIntegrationTests-h2.sql

@ -1,2 +0,0 @@ @@ -1,2 +0,0 @@
CREATE TABLE dummy_entity ( id BIGINT GENERATED BY DEFAULT AS IDENTITY ( START WITH 1 ) PRIMARY KEY, NAME VARCHAR(100), DELETED CHAR(1), log BIGINT);
CREATE TABLE log ( id BIGINT, TEXT VARCHAR(100));

2
spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository/JdbcRepositoryManipulateDbActionsIntegrationTests-hsql.sql

@ -1,2 +0,0 @@ @@ -1,2 +0,0 @@
CREATE TABLE dummy_entity ( id BIGINT GENERATED BY DEFAULT AS IDENTITY ( START WITH 1 ) PRIMARY KEY, NAME VARCHAR(100), DELETED CHAR(1), log BIGINT);
CREATE TABLE log ( id BIGINT, TEXT VARCHAR(100));

2
spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository/JdbcRepositoryManipulateDbActionsIntegrationTests-mariadb.sql

@ -1,2 +0,0 @@ @@ -1,2 +0,0 @@
CREATE TABLE dummy_entity ( id BIGINT AUTO_INCREMENT PRIMARY KEY, NAME VARCHAR(100), DELETED CHAR(1), log BIGINT);
CREATE TABLE log ( id BIGINT, TEXT VARCHAR(100));

4
spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository/JdbcRepositoryManipulateDbActionsIntegrationTests-mssql.sql

@ -1,4 +0,0 @@ @@ -1,4 +0,0 @@
DROP TABLE IF EXISTS dummy_entity;
DROP TABLE IF EXISTS log;
CREATE TABLE dummy_entity ( id BIGINT IDENTITY PRIMARY KEY, NAME VARCHAR(100), DELETED CHAR(1), log BIGINT);
CREATE TABLE log ( id BIGINT, TEXT VARCHAR(100));

2
spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository/JdbcRepositoryManipulateDbActionsIntegrationTests-mysql.sql

@ -1,2 +0,0 @@ @@ -1,2 +0,0 @@
CREATE TABLE dummy_entity ( id BIGINT AUTO_INCREMENT PRIMARY KEY, NAME VARCHAR(100), DELETED CHAR(1), log BIGINT);
CREATE TABLE log ( id BIGINT, TEXT VARCHAR(100));

4
spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository/JdbcRepositoryManipulateDbActionsIntegrationTests-postgres.sql

@ -1,4 +0,0 @@ @@ -1,4 +0,0 @@
DROP TABLE dummy_entity;
DROP TABLE log;
CREATE TABLE dummy_entity ( id SERIAL PRIMARY KEY, NAME VARCHAR(100), DELETED CHAR(5), log BIGINT);
CREATE TABLE log ( id BIGINT, TEXT VARCHAR(100));

11
spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository/JdbcRepositoryPropertyConversionIntegrationTests-db2.sql

@ -0,0 +1,11 @@ @@ -0,0 +1,11 @@
DROP TABLE ENTITY_WITH_COLUMNS_REQUIRING_CONVERSIONS;
CREATE TABLE ENTITY_WITH_COLUMNS_REQUIRING_CONVERSIONS (
id_Timestamp DATETIME NOT NULL PRIMARY KEY,
bool boolean, SOME_ENUM VARCHAR(100),
big_Decimal VARCHAR(100),
big_Integer BIGINT,
date DATETIME,
local_Date_Time DATETIME,
zoned_Date_Time VARCHAR(30)
);

7
spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository/JdbcRepositoryResultSetExtractorIntegrationTests-db2.sql

@ -0,0 +1,7 @@ @@ -0,0 +1,7 @@
DROP TABLE address;
DROP TABLE person;
CREATE TABLE person ( id BIGINT GENERATED BY DEFAULT AS IDENTITY ( START WITH 1 ) PRIMARY KEY, name VARCHAR(100));
CREATE TABLE address ( id BIGINT GENERATED BY DEFAULT AS IDENTITY ( START WITH 1 ) PRIMARY KEY, street VARCHAR(100), person_id BIGINT);
ALTER TABLE address ADD FOREIGN KEY (person_id) REFERENCES person(id);

5
spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository/JdbcRepositoryWithCollectionsIntegrationTests-db2.sql

@ -0,0 +1,5 @@ @@ -0,0 +1,5 @@
DROP TABLE element;
DROP TABLE dummy_entity;
CREATE TABLE dummy_entity ( id BIGINT GENERATED BY DEFAULT AS IDENTITY ( START WITH 1 ) PRIMARY KEY, NAME VARCHAR(100));
CREATE TABLE element (id BIGINT GENERATED BY DEFAULT AS IDENTITY (START WITH 1) PRIMARY KEY, content VARCHAR(100), dummy_entity BIGINT);

5
spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository/JdbcRepositoryWithListsIntegrationTests-db2.sql

@ -0,0 +1,5 @@ @@ -0,0 +1,5 @@
DROP TABLE element;
DROP TABLE dummy_entity;
CREATE TABLE dummy_entity ( id BIGINT GENERATED BY DEFAULT AS IDENTITY ( START WITH 1 ) PRIMARY KEY, NAME VARCHAR(100));
CREATE TABLE element (id BIGINT GENERATED BY DEFAULT AS IDENTITY (START WITH 1) PRIMARY KEY, content VARCHAR(100), Dummy_Entity_key BIGINT, dummy_entity BIGINT);

9
spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository/JdbcRepositoryWithMapsIntegrationTests-db2.sql

@ -0,0 +1,9 @@ @@ -0,0 +1,9 @@
DROP TABLE element;
DROP TABLE dummy_entity;
CREATE TABLE dummy_entity ( id BIGINT GENERATED BY DEFAULT AS IDENTITY ( START WITH 1 ) PRIMARY KEY, NAME VARCHAR(100));
CREATE TABLE element (id BIGINT GENERATED BY DEFAULT AS IDENTITY (START WITH 1) PRIMARY KEY, content VARCHAR(100), Dummy_Entity_key VARCHAR(100), dummy_entity BIGINT);
ALTER TABLE ELEMENT
ADD FOREIGN KEY (dummy_entity)
REFERENCES dummy_entity(id);

3
spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository/StringBasedJdbcQueryMappingConfigurationIntegrationTests-db2.sql

@ -0,0 +1,3 @@ @@ -0,0 +1,3 @@
DROP TABLE car;
CREATE TABLE car ( id BIGINT GENERATED BY DEFAULT AS IDENTITY ( START WITH 1 ) PRIMARY KEY, model VARCHAR(100));

3
spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.repository/StringBasedJdbcQueryMappingConfigurationIntegrationTests-h2.sql

@ -1 +1,4 @@ @@ -1 +1,4 @@
DROP TABLE car;
CREATE TABLE car ( id BIGINT GENERATED BY DEFAULT AS IDENTITY ( START WITH 1 ) PRIMARY KEY, model VARCHAR(100));

87
spring-data-relational/src/main/java/org/springframework/data/relational/core/dialect/Db2Dialect.java

@ -0,0 +1,87 @@ @@ -0,0 +1,87 @@
/*
* Copyright 2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.relational.core.dialect;
import org.springframework.data.relational.core.sql.IdentifierProcessing;
/**
* An SQL dialect for DB2.
*
* @author Jens Schauder
* @since 2.1
*/
public class Db2Dialect extends AbstractDialect {
/**
* Singleton instance.
*/
public static final Db2Dialect INSTANCE = new Db2Dialect();
protected Db2Dialect() {}
private static final LimitClause LIMIT_CLAUSE = new LimitClause() {
/*
* (non-Javadoc)
* @see org.springframework.data.relational.core.dialect.LimitClause#getLimit(long)
*/
@Override
public String getLimit(long limit) {
return "FIRST " + limit + " ROWS ONLY";
}
/*
* (non-Javadoc)
* @see org.springframework.data.relational.core.dialect.LimitClause#getOffset(long)
*/
@Override
public String getOffset(long offset) {
return "OFFSET " + offset + " ROWS";
}
/*
* (non-Javadoc)
* @see org.springframework.data.relational.core.dialect.LimitClause#getClause(long, long)
*/
@Override
public String getLimitOffset(long limit, long offset) {
return String.format("OFFSET %d ROWS FETCH FIRST %d ROWS ONLY", offset, limit);
}
/*
* (non-Javadoc)
* @see org.springframework.data.relational.core.dialect.LimitClause#getClausePosition()
*/
@Override
public Position getClausePosition() {
return Position.AFTER_ORDER_BY;
}
};
/*
* (non-Javadoc)
* @see org.springframework.data.relational.core.dialect.Dialect#limit()
*/
@Override
public LimitClause limit() {
return LIMIT_CLAUSE;
}
@Override
public IdentifierProcessing getIdentifierProcessing() {
return IdentifierProcessing.ANSI;
}
}
Loading…
Cancel
Save