From e17cb0dd1e90b6c06065d560145db3198c8386d3 Mon Sep 17 00:00:00 2001 From: Kirill Kurdyukov Date: Fri, 30 Aug 2024 18:08:28 +0300 Subject: [PATCH 1/2] feat: Spring Data JDBC added README.md and run examples --- .../workflows/ci-spring-data-jdbc-ydb.yaml | 26 +++---- hibernate-dialect/NOTES.md | 0 hibernate-dialect/README.md | 5 -- spring-data-jdbc-ydb/CHANGELOG.md | 5 ++ spring-data-jdbc-ydb/README.md | 74 +++++++++++++++++++ .../tech/ydb/data/YdbJdbcConfiguration.java | 5 +- 6 files changed, 95 insertions(+), 20 deletions(-) delete mode 100644 hibernate-dialect/NOTES.md create mode 100644 spring-data-jdbc-ydb/CHANGELOG.md diff --git a/.github/workflows/ci-spring-data-jdbc-ydb.yaml b/.github/workflows/ci-spring-data-jdbc-ydb.yaml index 334b496..5de0db4 100644 --- a/.github/workflows/ci-spring-data-jdbc-ydb.yaml +++ b/.github/workflows/ci-spring-data-jdbc-ydb.yaml @@ -46,16 +46,16 @@ jobs: working-directory: ./spring-data-jdbc-ydb run: mvn $MAVEN_ARGS install -# - uses: actions/checkout@v4 -# with: -# repository: ydb-platform/ydb-java-examples -# ref: master -# path: examples -# -# - name: Download dependencies -# working-directory: ./examples/jdbc/spring-data-jpa-v5 -# run: mvn $MAVEN_ARGS -Dspring.data.jdbc.ydb.dialect.version=$SPRING_DATA_JDBC_DIALECT_VERSION dependency:go-offline -# -# - name: Test examples with Maven -# working-directory: ./examples/jdbc/spring-data-jpa-v5 -# run: mvn $MAVEN_ARGS -Dspring.data.jdbc.ydb.dialect.version=$SPRING_DATA_JDBC_DIALECT_VERSION test + - uses: actions/checkout@v4 + with: + repository: ydb-platform/ydb-java-examples + ref: master + path: examples + + - name: Download dependencies + working-directory: ./examples/jdbc/spring-data-jdbc + run: mvn $MAVEN_ARGS -Dspring.data.jdbc.ydb.version=$SPRING_DATA_JDBC_DIALECT_VERSION dependency:go-offline + + - name: Test examples with Maven + working-directory: ./examples/jdbc/spring-data-jpa-v5 + run: mvn $MAVEN_ARGS -Dspring.data.jdbc.ydb.version=$SPRING_DATA_JDBC_DIALECT_VERSION test diff --git a/hibernate-dialect/NOTES.md b/hibernate-dialect/NOTES.md deleted file mode 100644 index e69de29..0000000 diff --git a/hibernate-dialect/README.md b/hibernate-dialect/README.md index 7ebf072..51791ea 100644 --- a/hibernate-dialect/README.md +++ b/hibernate-dialect/README.md @@ -89,11 +89,6 @@ spring.datasource.url=jdbc:ydb:grpc://localhost:2136/local An example of a simple Spring Data JPA repository can be found at the following [link](https://github.com/ydb-platform/ydb-java-examples/tree/master/jdbc/spring-data-jpa). -## Known Limitations - -In the section [NOTES.md](./NOTES.md), we list all the current dialect limitations -and provide solutions to them. - ## Support and Contact For support, you can open issues in the repository issue tracker with tag `hibernate-v6`. diff --git a/spring-data-jdbc-ydb/CHANGELOG.md b/spring-data-jdbc-ydb/CHANGELOG.md new file mode 100644 index 0000000..1e85961 --- /dev/null +++ b/spring-data-jdbc-ydb/CHANGELOG.md @@ -0,0 +1,5 @@ +## 0.9.1 ## + +- Supported VIEW INDEX statement from @ViewIndex +- YdbDialect fully supports YQL +- Supported specific @YdbType \ No newline at end of file diff --git a/spring-data-jdbc-ydb/README.md b/spring-data-jdbc-ydb/README.md index cfd65b5..10640cf 100644 --- a/spring-data-jdbc-ydb/README.md +++ b/spring-data-jdbc-ydb/README.md @@ -1 +1,75 @@ # YDB Spring Data JDBC Dialect + +[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/ydb-platform/ydb-java-dialects/blob/main/LICENSE.md) +[![Maven metadata URL](https://img.shields.io/maven-metadata/v?metadataUrl=https%3A%2F%2Frepo1.maven.org%2Fmaven2%2Ftech%2Fydb%2Fdialects%2Fspring-data-jdbc-ydb%2Fmaven-metadata.xml)](https://mvnrepository.com/artifact/tech.ydb.dialects/spring-data-jdbc-ydb) +[![CI](https://img.shields.io/github/actions/workflow/status/ydb-platform/ydb-java-dialects/ci-spring-data-jdbc-ydb.yaml?branch=main&label=CI)](https://github.com/ydb-platform/ydb-java-dialects/actions/workflows/ci-spring-data-jdbc-ydb.yaml) + +## Overview + +This project is an extension for Spring Data JDBC +that provides support for working with [YDB](https://ydb.tech). + +### Features + +- Full support for basic operations with Spring Data JDBC +- Supported VIEW INDEX statement from @ViewIndex annotation on method your Repository +- @YdbType explicitly specifies the YDB data type (Json example in String type) + +## Getting Started + +### Requirements + +To use this Spring Data JDBC YDB Dialect, you'll need: + +- Java 17 or above. +- Spring Data JDBC 3+ +- [YDB JDBC Driver](https://github.com/ydb-platform/ydb-jdbc-driver) +- Access to a YDB Database instance + +### Installation + +For Maven, add the following dependency to your pom.xml: + +```xml + + tech.ydb.dialects + spring-data-jdbc-ydb + + ${spring.data.jdbc.ydb.version} + +``` + +For Gradle, add the following to your build.gradle (or build.gradle.kts): + +```groovy +dependencies { + implementation 'tech.ydb.dialects:spring-data-jdbc-ydb:$version' // Set actual version +} +``` + +## Usage + +Use this custom dialect just like any other DBMS. + +## Configuration + +Configure Spring Data JDBC with YDB by updating your application.properties: + +```properties +spring.datasource.driver-class-name=tech.ydb.jdbc.YdbDriver +spring.datasource.url=jdbc:ydb:grpc://localhost:2136/local +``` + +Java configuration for @YdbType annotation: + +```java +@Import(AbstractYdbJdbcConfiguration.class) +public class YdbJdbcConfiguration {} +``` + +An example of a simple Spring Data JDBC repository can be found at the following +[link](https://github.com/ydb-platform/ydb-java-examples/tree/master/jdbc/spring-data-jdbc). + +## Support and Contact + +For support, you can open issues in the repository issue tracker with tag `spring-data-jdbc`. \ No newline at end of file diff --git a/spring-data-jdbc-ydb/src/test/java/tech/ydb/data/YdbJdbcConfiguration.java b/spring-data-jdbc-ydb/src/test/java/tech/ydb/data/YdbJdbcConfiguration.java index eb94106..87fc4ad 100644 --- a/spring-data-jdbc-ydb/src/test/java/tech/ydb/data/YdbJdbcConfiguration.java +++ b/spring-data-jdbc-ydb/src/test/java/tech/ydb/data/YdbJdbcConfiguration.java @@ -1,6 +1,7 @@ package tech.ydb.data; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Import; import org.springframework.data.jdbc.repository.config.EnableJdbcAuditing; import org.springframework.data.jdbc.repository.config.EnableJdbcRepositories; import tech.ydb.data.repository.config.AbstractYdbJdbcConfiguration; @@ -11,5 +12,5 @@ @Configuration @EnableJdbcRepositories @EnableJdbcAuditing -public class YdbJdbcConfiguration extends AbstractYdbJdbcConfiguration { -} +@Import(AbstractYdbJdbcConfiguration.class) +public class YdbJdbcConfiguration {} \ No newline at end of file From 17390e3840b5225b91cb0695fc81a41066d62bf4 Mon Sep 17 00:00:00 2001 From: Kirill Kurdyukov Date: Fri, 30 Aug 2024 18:11:32 +0300 Subject: [PATCH 2/2] feat: Spring Data JDBC added README.md and run examples --- .github/workflows/ci-spring-data-jdbc-ydb.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-spring-data-jdbc-ydb.yaml b/.github/workflows/ci-spring-data-jdbc-ydb.yaml index 5de0db4..d9042d4 100644 --- a/.github/workflows/ci-spring-data-jdbc-ydb.yaml +++ b/.github/workflows/ci-spring-data-jdbc-ydb.yaml @@ -57,5 +57,5 @@ jobs: run: mvn $MAVEN_ARGS -Dspring.data.jdbc.ydb.version=$SPRING_DATA_JDBC_DIALECT_VERSION dependency:go-offline - name: Test examples with Maven - working-directory: ./examples/jdbc/spring-data-jpa-v5 + working-directory: ./examples/jdbc/spring-data-jdbc run: mvn $MAVEN_ARGS -Dspring.data.jdbc.ydb.version=$SPRING_DATA_JDBC_DIALECT_VERSION test