Skip to content

Commit aa90634

Browse files
dev: prepare spring data jdbc ydb dialect (#139)
1 parent 41a1127 commit aa90634

39 files changed

+519
-449
lines changed
+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Spring Data JDBC YDB Dialect CI with Maven
2+
3+
on:
4+
push:
5+
paths:
6+
- 'spring-data-dialect/**'
7+
branches:
8+
- main
9+
pull_request:
10+
paths:
11+
- 'spring-data-dialect/**'
12+
13+
env:
14+
MAVEN_ARGS: --batch-mode --update-snapshots -Dstyle.color=always
15+
16+
jobs:
17+
build:
18+
name: Spring Data JDBC YDB Dialect
19+
runs-on: ubuntu-latest
20+
21+
strategy:
22+
matrix:
23+
java: [ '17', '21' ]
24+
25+
steps:
26+
- uses: actions/checkout@v4
27+
28+
- name: Set up JDK ${{matrix.java}}
29+
uses: actions/setup-java@v4
30+
with:
31+
java-version: ${{matrix.java}}
32+
distribution: 'temurin'
33+
cache: maven
34+
35+
- name: Extract spring-data-jdbc YDB dialect version
36+
working-directory: ./spring-data-dialect
37+
run: |
38+
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
39+
echo "SPRING_DATA_JDBC_DIALECT_VERSION=$VERSION" >> "$GITHUB_ENV"
40+
41+
- name: Download spring-data-jdbc YDB dialect dependencies
42+
working-directory: ./spring-data-dialect
43+
run: mvn $MAVEN_ARGS dependency:go-offline
44+
45+
- name: Build spring-data-jdbc YDB dialect
46+
working-directory: ./spring-data-dialect
47+
run: mvn $MAVEN_ARGS install
48+
49+
# - uses: actions/checkout@v4
50+
# with:
51+
# repository: ydb-platform/ydb-java-examples
52+
# ref: master
53+
# path: examples
54+
#
55+
# - name: Download dependencies
56+
# working-directory: ./examples/jdbc/spring-data-jpa-v5
57+
# run: mvn $MAVEN_ARGS -Dspring.data.jdbc.ydb.dialect.version=$SPRING_DATA_JDBC_DIALECT_VERSION dependency:go-offline
58+
#
59+
# - name: Test examples with Maven
60+
# working-directory: ./examples/jdbc/spring-data-jpa-v5
61+
# run: mvn $MAVEN_ARGS -Dspring.data.jdbc.ydb.dialect.version=$SPRING_DATA_JDBC_DIALECT_VERSION test
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: Publish Spring Data JDBC YDB Dialect
2+
3+
on:
4+
push:
5+
tags:
6+
- 'spring-data-jdbc-ydb/v[0-9]+.[0-9]+.[0-9]+'
7+
8+
env:
9+
MAVEN_ARGS: --batch-mode --no-transfer-progress -Dstyle.color=always
10+
11+
jobs:
12+
validate:
13+
name: Validate Spring Data JDBC YDB Dialect
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Extract spring-data-jdbc YDB dialect version
20+
run: |
21+
cd spring-data-dialect
22+
SPRING_DATA_JDBC_DIALECT_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
23+
echo "SPRING_DATA_JDBC_DIALECT_VERSION=SPRING_DATA_JDBC_DIALECT_VERSION" >> "$GITHUB_ENV"
24+
25+
- name: Fail workflow if version is snapshot
26+
if: endsWith(env.SPRING_DATA_JDBC_DIALECT_VERSION, 'SNAPSHOT')
27+
uses: actions/github-script@v6
28+
with:
29+
script: core.setFailed('SNAPSHOT version cannot be published')
30+
31+
- name: Fail workflow if version is not equal to tag name
32+
if: format('spring-data-jdbc-ydb/v{0}', env.SPRING_DATA_JDBC_DIALECT_VERSION) != github.ref_name
33+
uses: actions/github-script@v6
34+
with:
35+
script: core.setFailed('Release name must be equal to project version')
36+
37+
- name: Set up JDK
38+
uses: actions/setup-java@v4
39+
with:
40+
java-version: 17
41+
distribution: 'temurin'
42+
cache: 'maven'
43+
44+
- name: Download dependencies
45+
run: |
46+
cd spring-data-dialect
47+
mvn $MAVEN_ARGS dependency:go-offline
48+
49+
- name: Build with Maven
50+
run: |
51+
cd spring-data-dialect
52+
mvn $MAVEN_ARGS package
53+
54+
publish:
55+
name: Publish Spring Data JDBC YDB Dialect
56+
runs-on: ubuntu-latest
57+
needs: validate
58+
59+
steps:
60+
- name: Install gpg secret key
61+
run: |
62+
# Install gpg secret key
63+
cat <(echo -e "${{ secrets.MAVEN_OSSRH_GPG_SECRET_KEY }}") | gpg --batch --import
64+
# Verify gpg secret key
65+
gpg --list-secret-keys --keyid-format LONG
66+
67+
- uses: actions/checkout@v4
68+
69+
- name: Set up Maven Central Repository
70+
uses: actions/setup-java@v4
71+
with:
72+
java-version: 17
73+
distribution: 'temurin'
74+
cache: 'maven'
75+
server-id: ossrh-s01
76+
server-username: MAVEN_USERNAME
77+
server-password: MAVEN_PASSWORD
78+
79+
- name: Publish package
80+
run: |
81+
cd spring-data-dialect
82+
mvn $MAVEN_ARGS -Possrh-s01 -Dgpg.passphrase=${{ secrets.MAVEN_OSSRH_GPG_PASSWORD }} clean deploy
83+
env:
84+
MAVEN_USERNAME: ${{ secrets.MAVEN_OSSRH_USERNAME }}
85+
MAVEN_PASSWORD: ${{ secrets.MAVEN_OSSRH_TOKEN }}

jooq-dialect/src/test/java/tech/ydb/jooq/InsertTest.java

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
package tech.ydb.jooq;
22

3+
import java.util.List;
4+
import static jooq.generated.ydb.default_schema.Tables.HARD_TABLE;
5+
import static jooq.generated.ydb.default_schema.Tables.SERIES;
36
import jooq.generated.ydb.default_schema.tables.records.HardTableRecord;
47
import jooq.generated.ydb.default_schema.tables.records.SeriesRecord;
58
import org.jooq.JSON;
69
import org.jooq.JSONB;
710
import org.jooq.Result;
811
import org.jooq.exception.DataAccessException;
912
import org.jooq.types.ULong;
13+
import static org.junit.jupiter.api.Assertions.assertEquals;
14+
import static org.junit.jupiter.api.Assertions.assertThrows;
1015
import org.junit.jupiter.api.Test;
1116
import tech.ydb.jooq.value.YSON;
1217

13-
import java.util.List;
14-
15-
import static jooq.generated.ydb.default_schema.Tables.HARD_TABLE;
16-
import static jooq.generated.ydb.default_schema.Tables.SERIES;
17-
import static org.junit.jupiter.api.Assertions.*;
18-
1918
public class InsertTest extends BaseTest {
2019

2120
@Test

spring-data-dialect/pom.xml

+121-12
Original file line numberDiff line numberDiff line change
@@ -8,36 +8,54 @@
88
<artifactId>spring-data-ydb-dialect</artifactId>
99
<version>0.9.1-SNAPSHOT</version>
1010

11-
<name>Spring Data YDB Dialect</name>
11+
<name>Spring Data JDBC YDB Dialect</name>
1212
<description>Support Spring Data JDBC YDB (YQL) Dialect</description>
1313
<url>https://github.com/ydb-platform/ydb-java-dialects</url>
1414

15+
<packaging>jar</packaging>
16+
1517
<developers>
1618
<developer>
1719
<name>Madiyar Nurgazin</name>
1820
<email>[email protected]</email>
1921
<organization>YDB</organization>
2022
<organizationUrl>https://ydb.tech/</organizationUrl>
2123
</developer>
24+
<developer>
25+
<name>Kirill Kurdyukov</name>
26+
<email>[email protected]</email>
27+
<organization>YDB</organization>
28+
<organizationUrl>https://ydb.tech/</organizationUrl>
29+
</developer>
2230
</developers>
2331

32+
<scm>
33+
<url>https://github.com/ydb-platform/ydb-java-dialects</url>
34+
<connection>scm:git:https://github.com/ydb-platform/ydb-java-dialects.git</connection>
35+
<developerConnection>scm:git:https://github.com/ydb-platform/ydb-java-dialects.git</developerConnection>
36+
</scm>
37+
38+
<licenses>
39+
<license>
40+
<name>Apache License, Version 2.0</name>
41+
<url>https://www.apache.org/licenses/LICENSE-2.0</url>
42+
</license>
43+
</licenses>
44+
2445
<properties>
2546
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
2647

2748
<maven.compiler.release>17</maven.compiler.release>
28-
2949
<maven.compiler.target>17</maven.compiler.target>
3050
<maven.compiler.source>17</maven.compiler.source>
3151

32-
<springdata.jdbc.version>3.2.4</springdata.jdbc.version>
33-
3452
<junit5.version>5.10.2</junit5.version>
3553
<lombok.version>1.18.30</lombok.version>
36-
<spring.boot.version>3.2.3</spring.boot.version>
54+
<spring.version>3.2.1</spring.version>
3755
<liquibase.version>4.24.0</liquibase.version>
3856

39-
<ydb.sdk.version>2.2.6</ydb.sdk.version>
40-
<ydb.jdbc.version>2.1.5</ydb.jdbc.version>
57+
<ydb.sdk.version>2.2.9</ydb.sdk.version>
58+
<ydb.jdbc.version>2.2.3</ydb.jdbc.version>
4159
<ydb.liquibase.version>0.9.7</ydb.liquibase.version>
4260
</properties>
4361

@@ -50,21 +68,29 @@
5068
<type>pom</type>
5169
<scope>import</scope>
5270
</dependency>
71+
<dependency>
72+
<groupId>org.springframework.boot</groupId>
73+
<artifactId>spring-boot-dependencies</artifactId>
74+
<version>${spring.version}</version>
75+
<scope>import</scope>
76+
<type>pom</type>
77+
</dependency>
5378
</dependencies>
5479
</dependencyManagement>
5580

5681
<dependencies>
5782
<dependency>
5883
<groupId>org.springframework.data</groupId>
5984
<artifactId>spring-data-jdbc</artifactId>
60-
<version>${springdata.jdbc.version}</version>
6185
<scope>provided</scope>
6286
</dependency>
6387
<dependency>
6488
<groupId>tech.ydb.jdbc</groupId>
65-
<artifactId>ydb-jdbc-driver-shaded</artifactId>
89+
<artifactId>ydb-jdbc-driver</artifactId>
6690
<version>${ydb.jdbc.version}</version>
91+
<scope>provided</scope>
6792
</dependency>
93+
6894
<dependency>
6995
<groupId>tech.ydb.test</groupId>
7096
<artifactId>ydb-junit5-support</artifactId>
@@ -73,7 +99,6 @@
7399
<dependency>
74100
<groupId>org.junit.jupiter</groupId>
75101
<artifactId>junit-jupiter-api</artifactId>
76-
<version>${junit5.version}</version>
77102
<scope>test</scope>
78103
</dependency>
79104
<dependency>
@@ -85,13 +110,11 @@
85110
<dependency>
86111
<groupId>org.springframework.boot</groupId>
87112
<artifactId>spring-boot-starter-test</artifactId>
88-
<version>${spring.boot.version}</version>
89113
<scope>test</scope>
90114
</dependency>
91115
<dependency>
92116
<groupId>org.springframework.boot</groupId>
93117
<artifactId>spring-boot-starter-jdbc</artifactId>
94-
<version>${spring.boot.version}</version>
95118
<scope>test</scope>
96119
</dependency>
97120
<dependency>
@@ -107,4 +130,90 @@
107130
<scope>test</scope>
108131
</dependency>
109132
</dependencies>
133+
<build>
134+
<plugins>
135+
<plugin>
136+
<groupId>org.apache.maven.plugins</groupId>
137+
<artifactId>maven-javadoc-plugin</artifactId>
138+
<version>3.5.0</version>
139+
<configuration>
140+
<source>17</source>
141+
</configuration>
142+
<executions>
143+
<execution>
144+
<id>attach-javadocs</id>
145+
<goals>
146+
<goal>jar</goal>
147+
</goals>
148+
</execution>
149+
</executions>
150+
</plugin>
151+
<plugin>
152+
<groupId>org.apache.maven.plugins</groupId>
153+
<artifactId>maven-source-plugin</artifactId>
154+
<version>3.2.1</version>
155+
<executions>
156+
<execution>
157+
<id>attach-sources</id>
158+
<goals>
159+
<goal>jar-no-fork</goal>
160+
</goals>
161+
</execution>
162+
</executions>
163+
</plugin>
164+
<plugin>
165+
<groupId>org.apache.maven.plugins</groupId>
166+
<artifactId>maven-surefire-plugin</artifactId>
167+
<version>3.1.0</version>
168+
<configuration>
169+
<environmentVariables>
170+
<TESTCONTAINERS_REUSE_ENABLE>true</TESTCONTAINERS_REUSE_ENABLE>
171+
</environmentVariables>
172+
</configuration>
173+
</plugin>
174+
</plugins>
175+
</build>
176+
<profiles>
177+
<profile>
178+
<id>ossrh-s01</id>
179+
<activation>
180+
<activeByDefault>false</activeByDefault>
181+
</activation>
182+
<build>
183+
<plugins>
184+
<plugin>
185+
<groupId>org.apache.maven.plugins</groupId>
186+
<artifactId>maven-gpg-plugin</artifactId>
187+
<version>1.6</version>
188+
<executions>
189+
<execution>
190+
<id>sign-artifacts</id>
191+
<phase>verify</phase>
192+
<goals>
193+
<goal>sign</goal>
194+
</goals>
195+
</execution>
196+
</executions>
197+
<configuration>
198+
<gpgArguments>
199+
<arg>--pinentry-mode</arg>
200+
<arg>loopback</arg>
201+
</gpgArguments>
202+
</configuration>
203+
</plugin>
204+
<plugin>
205+
<groupId>org.sonatype.plugins</groupId>
206+
<artifactId>nexus-staging-maven-plugin</artifactId>
207+
<version>1.6.8</version>
208+
<extensions>true</extensions>
209+
<configuration>
210+
<serverId>ossrh-s01</serverId>
211+
<nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
212+
<autoReleaseAfterClose>false</autoReleaseAfterClose>
213+
</configuration>
214+
</plugin>
215+
</plugins>
216+
</build>
217+
</profile>
218+
</profiles>
110219
</project>

spring-data-dialect/src/main/java/tech/ydb/data/core/convert/YQLType.java

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package tech.ydb.data.core.convert;
22

33
import java.sql.SQLType;
4-
54
import tech.ydb.jdbc.YdbConst;
65
import tech.ydb.table.values.PrimitiveType;
76

0 commit comments

Comments
 (0)