Skip to content

Commit 354bbb4

Browse files
committed
Merge branch 'master' into develop
2 parents 22dee7c + 9bebfc2 commit 354bbb4

37 files changed

+1793
-14
lines changed

.github/workflows/build.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ jobs:
2222

2323
steps:
2424
- name: Checkout
25-
uses: actions/checkout@v3
25+
uses: actions/checkout@v4
2626

2727
- name: Set up JDK
28-
uses: actions/setup-java@v3
28+
uses: actions/setup-java@v4
2929
with:
3030
java-version: ${{ matrix.java }}
3131
distribution: 'temurin'

.github/workflows/validate.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ jobs:
1919

2020
steps:
2121
- name: Checkout
22-
uses: actions/checkout@v3
22+
uses: actions/checkout@v4
2323

2424
- name: Set up JDK
25-
uses: actions/setup-java@v3
25+
uses: actions/setup-java@v4
2626
with:
2727
java-version: ${{ matrix.java }}
2828
distribution: 'temurin'

jdbc/pom.xml

+15-2
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@
1515
<packaging>pom</packaging>
1616

1717
<properties>
18-
<ydb.jdbc.version>2.0.2</ydb.jdbc.version>
19-
<slf4j.version>1.7.25</slf4j.version>
18+
<ydb.jdbc.version>2.0.6</ydb.jdbc.version>
19+
<slf4j.version>1.7.36</slf4j.version>
2020
</properties>
2121

2222
<modules>
2323
<module>basic-example</module>
24+
<module>spring-data-jpa-v5</module>
2425
</modules>
2526

2627
<dependencyManagement>
@@ -38,4 +39,16 @@
3839
</dependency>
3940
</dependencies>
4041
</dependencyManagement>
42+
43+
<profiles>
44+
<profile>
45+
<id>jdk17-examples</id>
46+
<activation>
47+
<jdk>[17</jdk>
48+
</activation>
49+
<modules>
50+
<module>spring-data-jpa</module>
51+
</modules>
52+
</profile>
53+
</profiles>
4154
</project>

jdbc/spring-data-jpa-v5/pom.xml

+147
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
2+
<modelVersion>4.0.0</modelVersion>
3+
<parent>
4+
<groupId>tech.ydb.jdbc.examples</groupId>
5+
<artifactId>ydb-jdbc-examples</artifactId>
6+
<version>1.1.0-SNAPSHOT</version>
7+
</parent>
8+
9+
<artifactId>spring-data-jpa-v5</artifactId>
10+
<name>Spring Data JPA Example Hibernate 5</name>
11+
<description>Basic example for SpringBoot3 and Hibernate 6</description>
12+
<properties>
13+
<kotlin.version>1.9.22</kotlin.version>
14+
<hibernate.ydb.dialect.version>0.9.1</hibernate.ydb.dialect.version>
15+
<spring.boot.version>2.5.7</spring.boot.version>
16+
</properties>
17+
<dependencies>
18+
<dependency>
19+
<groupId>org.springframework.boot</groupId>
20+
<artifactId>spring-boot-starter-data-jpa</artifactId>
21+
<version>${spring.boot.version}</version>
22+
</dependency>
23+
<dependency>
24+
<groupId>org.springframework.data</groupId>
25+
<artifactId>spring-data-commons</artifactId>
26+
<version>${spring.boot.version}</version>
27+
</dependency>
28+
<dependency>
29+
<groupId>org.jetbrains.kotlin</groupId>
30+
<artifactId>kotlin-reflect</artifactId>
31+
<version>${kotlin.version}</version>
32+
</dependency>
33+
<dependency>
34+
<groupId>org.jetbrains.kotlin</groupId>
35+
<artifactId>kotlin-stdlib</artifactId>
36+
<version>${kotlin.version}</version>
37+
</dependency>
38+
<dependency>
39+
<groupId>tech.ydb.dialects</groupId>
40+
<artifactId>hibernate-ydb-dialect-v5</artifactId>
41+
<version>${hibernate.ydb.dialect.version}</version>
42+
</dependency>
43+
<dependency>
44+
<groupId>tech.ydb.jdbc</groupId>
45+
<artifactId>ydb-jdbc-driver-shaded</artifactId>
46+
</dependency>
47+
<dependency>
48+
<groupId>com.github.javafaker</groupId>
49+
<artifactId>javafaker</artifactId>
50+
<version>1.0.2</version>
51+
</dependency>
52+
<dependency>
53+
<groupId>org.jetbrains.kotlinx</groupId>
54+
<artifactId>kotlinx-coroutines-core</artifactId>
55+
<version>1.7.3</version>
56+
</dependency>
57+
<dependency>
58+
<groupId>org.postgresql</groupId>
59+
<artifactId>postgresql</artifactId>
60+
<version>42.7.1</version>
61+
</dependency>
62+
<dependency>
63+
<groupId>org.testcontainers</groupId>
64+
<artifactId>postgresql</artifactId>
65+
<version>1.19.1</version>
66+
<scope>test</scope>
67+
</dependency>
68+
<dependency>
69+
<groupId>tech.ydb.test</groupId>
70+
<artifactId>ydb-junit5-support</artifactId>
71+
<scope>test</scope>
72+
<exclusions>
73+
<exclusion>
74+
<groupId>org.junit.jupiter</groupId>
75+
<artifactId>junit-jupiter-api</artifactId>
76+
</exclusion>
77+
</exclusions>
78+
</dependency>
79+
<dependency>
80+
<groupId>org.springframework.boot</groupId>
81+
<artifactId>spring-boot-starter-test</artifactId>
82+
<version>${spring.boot.version}</version>
83+
<scope>test</scope>
84+
</dependency>
85+
</dependencies>
86+
<build>
87+
<sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
88+
<testSourceDirectory>${project.basedir}/src/test/kotlin</testSourceDirectory>
89+
<plugins>
90+
<plugin>
91+
<groupId>org.apache.maven.plugins</groupId>
92+
<artifactId>maven-surefire-plugin</artifactId>
93+
<configuration>
94+
<environmentVariables>
95+
<TESTCONTAINERS_REUSE_ENABLE>true</TESTCONTAINERS_REUSE_ENABLE>
96+
</environmentVariables>
97+
</configuration>
98+
</plugin>
99+
<plugin>
100+
<groupId>org.springframework.boot</groupId>
101+
<artifactId>spring-boot-maven-plugin</artifactId>
102+
<version>${spring.boot.version}</version>
103+
</plugin>
104+
<plugin>
105+
<groupId>org.jetbrains.kotlin</groupId>
106+
<artifactId>kotlin-maven-plugin</artifactId>
107+
<version>${kotlin.version}</version>
108+
<executions>
109+
<execution>
110+
<id>compile</id>
111+
<phase>compile</phase>
112+
<goals>
113+
<goal>compile</goal>
114+
</goals>
115+
</execution>
116+
<execution>
117+
<id>test-compile</id>
118+
<goals>
119+
<goal>test-compile</goal>
120+
</goals>
121+
</execution>
122+
</executions>
123+
<configuration>
124+
<args>
125+
<arg>-Xjsr305=strict</arg>
126+
</args>
127+
<compilerPlugins>
128+
<plugin>spring</plugin>
129+
<plugin>jpa</plugin>
130+
</compilerPlugins>
131+
</configuration>
132+
<dependencies>
133+
<dependency>
134+
<groupId>org.jetbrains.kotlin</groupId>
135+
<artifactId>kotlin-maven-allopen</artifactId>
136+
<version>${kotlin.version}</version>
137+
</dependency>
138+
<dependency>
139+
<groupId>org.jetbrains.kotlin</groupId>
140+
<artifactId>kotlin-maven-noarg</artifactId>
141+
<version>${kotlin.version}</version>
142+
</dependency>
143+
</dependencies>
144+
</plugin>
145+
</plugins>
146+
</build>
147+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package tech.ydb.jpa.pagination
2+
3+
import javax.persistence.Entity
4+
import javax.persistence.Id
5+
import javax.persistence.Table
6+
7+
@Entity
8+
@Table(name = "authors")
9+
class Author {
10+
11+
@Id
12+
lateinit var id: String
13+
14+
lateinit var firstName: String
15+
16+
lateinit var lastName: String
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package tech.ydb.jpa.pagination
2+
3+
import java.util.*
4+
import javax.persistence.*
5+
6+
@Entity
7+
@Table(name = "books")
8+
class Book {
9+
10+
@Id
11+
lateinit var id: String
12+
13+
lateinit var title: String
14+
lateinit var isbn10: String
15+
lateinit var publicationDate: Date
16+
17+
@ManyToOne
18+
lateinit var author: Author
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package tech.ydb.jpa.pagination
2+
3+
import org.springframework.data.domain.*
4+
import org.springframework.data.jpa.repository.Query
5+
import org.springframework.data.repository.CrudRepository
6+
import org.springframework.data.repository.query.Param
7+
8+
interface BookRepository : CrudRepository<Book, String> {
9+
10+
/**
11+
* Uses an offset based pagination that first sorts the entries by their [ publication_date][Book.getPublicationDate]
12+
* and then limits the result by dropping the number of rows specified in the
13+
* [offset][Pageable.getOffset] clause. To retrieve [Page.getTotalElements] an additional count query
14+
* is executed.
15+
*
16+
* @param title
17+
* @param pageable
18+
*/
19+
@Query(
20+
"SELECT * FROM books WHERE books.title LIKE %:title% ORDER BY books.publication_date",
21+
countQuery = "SELECT count(*) FROM books WHERE books.title LIKE %:title%",
22+
nativeQuery = true
23+
)
24+
fun findByTitleContainsOrderByPublicationDate(@Param("title") title: String, pageable: Pageable): Page<Book>
25+
26+
/**
27+
* Uses an offset based slicing that first sorts the entries by their [ publication_date][Book.getPublicationDate]
28+
* and then limits the result by dropping the number of rows specified in the
29+
* [offset][Pageable.getOffset] clause.
30+
*
31+
* @param title
32+
* @param pageable
33+
*/
34+
@Query(
35+
"SELECT * FROM books WHERE books.title LIKE %:title% ORDER BY books.publication_date",
36+
nativeQuery = true
37+
)
38+
fun findBooksByTitleContainsOrderByPublicationDate(title: String, pageable: Pageable): Slice<Book>
39+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package tech.ydb.jpa.pagination
2+
3+
import org.springframework.boot.autoconfigure.SpringBootApplication
4+
5+
@SpringBootApplication
6+
class PagingApplication

0 commit comments

Comments
 (0)