Skip to content

Commit

Permalink
initial commit of keyset pagination using spring-data-jpa (#1482)
Browse files Browse the repository at this point in the history
* rename : directory

* initial commit of keyset pagination
  • Loading branch information
rajadilipkolli authored Nov 1, 2024
1 parent 13c2007 commit 1570a95
Show file tree
Hide file tree
Showing 113 changed files with 2,179 additions and 12 deletions.
15 changes: 10 additions & 5 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,6 @@
- changed-files:
- any-glob-to-any-file:
- jpa/boot-data-envers/**/*
"component: keyset-pagination-blaze":
- changed-files:
- any-glob-to-any-file:
- jpa/boot-data-keyset-pagination/blaze-persistence/**/*
"component: multiple-datasources":
- changed-files:
- any-glob-to-any-file:
Expand All @@ -86,6 +82,14 @@
- changed-files:
- any-glob-to-any-file:
- jpa/boot-read-replica-postgresql/**/*
"component: keyset-pagination-blaze":
- changed-files:
- any-glob-to-any-file:
- jpa/keyset-pagination/blaze-persistence/**/*
"component: keyset-pagination-data-jpa":
- changed-files:
- any-glob-to-any-file:
- jpa/keyset-pagination/boot-data-window-paginiation/**/*
"component: jpa-multitenancy":
- changed-files:
- any-glob-to-any-file:
Expand Down Expand Up @@ -139,11 +143,12 @@
- jmh-benchmark/pom.xml
- jpa/boot-data-customsequence/pom.xml
- jpa/boot-data-envers/pom.xml
- jpa/boot-data-keyset-pagination/blaze-persistence/pom.xml
- jpa/boot-data-multipledatasources/pom.xml
- jpa/boot-hibernate2ndlevelcache-sample/pom.xml
- jpa/boot-data-jpa-locks/pom.xml
- jpa/boot-read-replica-postgresql/pom.xml
- jpa/keyset-pagination/blaze-persistence/pom.xml
- jpa/keyset-pagination/boot-data-window-paginiation/pom.xml
- jpa/multitenancy/multitenancy-db/pom.xml
- jpa/multitenancy/multidatasource-multitenancy/pom.xml
- jpa/multitenancy/partition/pom.xml
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/boot-jpa-keyset-pagination-blaze.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ name: boot-data-keyset-pagination-blaze
on:
push:
paths:
- "jpa/boot-data-keyset-pagination/blaze-persistence/**"
- "jpa/keyset-pagination/blaze-persistence/**"
branches: [main]
pull_request:
paths:
- "jpa/boot-data-keyset-pagination/blaze-persistence/**"
- "jpa/keyset-pagination/blaze-persistence/**"
types:
- opened
- synchronize
Expand All @@ -19,7 +19,7 @@ jobs:
runs-on: ubuntu-latest
defaults:
run:
working-directory: "jpa/boot-data-keyset-pagination/blaze-persistence"
working-directory: "jpa/keyset-pagination/blaze-persistence"
steps:
- uses: actions/checkout@v4
with:
Expand Down
39 changes: 39 additions & 0 deletions .github/workflows/boot-jpa-keyset-pagination-data-jpa.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: boot-data-keyset-pagination

on:
push:
paths:
- "jpa/keyset-pagination/boot-data-window-paginiation/**"
branches: [main]
pull_request:
paths:
- "jpa/keyset-pagination/boot-data-window-paginiation/**"
types:
- opened
- synchronize
- reopened

jobs:
build:
name: Run Unit & Integration Tests
runs-on: ubuntu-latest
defaults:
run:
working-directory: "jpa/keyset-pagination/boot-data-window-paginiation"
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis

- name: Set up JDK 21
uses: actions/[email protected]
with:
java-version: 21
distribution: "temurin"
cache: "maven"

- name: Grant execute permission for mvnw
run: chmod +x mvnw

- name: Build and analyze
run: ./mvnw clean verify
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ The following table list all sample codes related to the spring boot integration
| [Spring Batch Implementation](./batch-boot-jpa-sample) | The application, demonstrates implementing Spring Batch 5 using simple config and creating batch tables using liquibase | Completed |
| [Rest API Documentation with examples](./boot-rest-docs-sample) | This application, demonstrates ability to generate pdf API documentation using spring rest docs | Completed |
| [Custom SequenceNumber and LazyConnectionDataSourceProxy for db connection improvement](./jpa/boot-data-customsequence) | This application, demonstrated ability to create custom sequences, using datasource-proxy and LazyConnectionDataSourceProxy for db connection improvement using mariadb | Completed |
| [KeySet pagination and dynamic search](./jpa/boot-data-keyset-pagination/blaze-persistence/) | Implements KeySet Pagination using Blaze Persistence and enable dynamic search using specifications | Completed |
| [KeySet pagination and dynamic search](./jpa/keyset-pagination/blaze-persistence/) | Implements KeySet Pagination using Blaze Persistence and enable dynamic search using specifications | Completed |

For More info about this repository, Please visit [here](https://rajadilipkolli.github.io/my-spring-boot-experiments/)

Expand Down
3 changes: 2 additions & 1 deletion SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@
* [jpa](jpa/README.md)
* [Custom Sequence](jpa/boot-data-customsequence/README.md)
* [Hibernate Envers Implementation](jpa/boot-data-envers/README.md)
* [KeySet Pagination Using Blaze](jpa/boot-data-keyset-pagination/blaze-persistence/README.md)
* [multiple datasources using Spring Boot](jpa/boot-data-multipledatasources/README.md),
* [spring-boot-hibernate2ndlevelcache-sample](jpa/boot-hibernate2ndlevelcache-sample/README.md)
* [JNDI in embedded Tomcat](jpa/boot-jndi-sample/README.md)
* [JPA locks implementation](jpa/boot-jpa-locks/README.md)
* [read-replica-with-spring-boot](jpa/boot-read-replica-postgresql/README.md)
* [KeySet Pagination Using Blaze](jpa/keyset-pagination/blaze-persistence/README.md)
* [KeySet Pagination Using Data-JPA](jpa/keyset-pagination/boot-data-window-pagination/README.md)
* [MultiTenancy using Hibernate in Spring Data JPA](jpa/multitenancy/README.md)
* [multitenancy-db](jpa/multitenancy/multitenancy-db/README.md)
* [multidatasource-multitenancy](jpa/multitenancy/multidatasource-multitenancy/README.md)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example.keysetpagination</groupId>
<artifactId>boot-data-keyset-pagination</artifactId>
<artifactId>boot-data-keyset-pagination-blaze</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>boot-data-keyset-pagination</name>
<name>boot-data-keyset-pagination-blaze</name>
<description>boot-data-keyset-pagination</description>

<properties>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: CI Build

on:
push:
branches:
- "**"

jobs:
build:
name: Build
runs-on: ubuntu-latest
strategy:
matrix:
distribution: [ 'temurin' ]
java: [ '17' ]
steps:
- uses: actions/checkout@v4

- name: Setup Java ${{ matrix.java }}
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java }}
distribution: ${{ matrix.distribution }}
cache: 'maven'

- name: Grant execute permission for mvnw
run: chmod +x mvnw

- name: Build with Maven
run: ./mvnw clean verify

- if: ${{ github.ref == 'refs/heads/main' }}
name: SonarQube Scan
run: ./mvnw compile sonar:sonar -Dsonar.login=${{ secrets.SONAR_TOKEN }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- if: ${{ github.ref == 'refs/heads/main' }}
name: Build and Publish Docker Image
run: |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
./mvnw spring-boot:build-image -Dspring-boot.build-image.imageName=${{ secrets.DOCKER_USERNAME }}/boot-data-window-paginiation
docker push ${{ secrets.DOCKER_USERNAME }}/boot-data-window-paginiation
37 changes: 37 additions & 0 deletions jpa/keyset-pagination/boot-data-window-paginiation/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/

### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache

### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/

### VS Code ###
.vscode/

### Misc ###
*.log
.DS_Store
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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
#
# http://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.
wrapperVersion=3.3.2
distributionType=only-script
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.8/apache-maven-3.9.8-bin.zip
13 changes: 13 additions & 0 deletions jpa/keyset-pagination/boot-data-window-paginiation/.yo-rc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"generator-springboot": {
"appName": "boot-data-window-paginiation",
"packageName": "com.example.keysetpagination",
"databaseType": "postgresql",
"dbMigrationTool": "liquibase",
"dbMigrationFormat": "xml",
"features": [],
"buildTool": "maven",
"packageFolder": "com/example/keysetpagination",
"liquibaseMigrationCounter": 2
}
}
14 changes: 14 additions & 0 deletions jpa/keyset-pagination/boot-data-window-paginiation/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM eclipse-temurin:17.0.11_9-jre-focal as builder
WORKDIR application
ARG JAR_FILE=target/boot-data-window-paginiation-0.0.1-SNAPSHOT.jar
COPY ${JAR_FILE} application.jar
RUN java -Djarmode=layertools -jar application.jar extract

# the second stage of our build will copy the extracted layers
FROM eclipse-temurin:17.0.11_9-jre-focal
WORKDIR application
COPY --from=builder application/dependencies/ ./
COPY --from=builder application/spring-boot-loader/ ./
COPY --from=builder application/snapshot-dependencies/ ./
COPY --from=builder application/application/ ./
ENTRYPOINT ["java", "org.springframework.boot.loader.JarLauncher"]
19 changes: 19 additions & 0 deletions jpa/keyset-pagination/boot-data-window-paginiation/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
pipeline {
agent any

triggers {
pollSCM('* * * * *')
}

environment {
APPLICATION_NAME = 'boot-data-window-paginiation'
}

stages {
stage('Build') {
steps {
sh './mvnw clean verify'
}
}
}
}
33 changes: 33 additions & 0 deletions jpa/keyset-pagination/boot-data-window-paginiation/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# boot-data-window-paginiation

### Format code

```shell
$ ./mvnw spotless:apply
```

### Run tests

```shell
$ ./mvnw clean verify
```

### Run locally

```shell
$ docker-compose -f docker/docker-compose.yml up -d
$ ./mvnw spring-boot:run -Dspring-boot.run.profiles=local
```

### Using Testcontainers at Development Time
You can run `TestApplication.java` from your IDE directly.
You can also run the application using Maven as follows:

```shell
./mvnw spring-boot:test-run
```


### Useful Links
* Swagger UI: http://localhost:8080/swagger-ui.html
* Actuator Endpoint: http://localhost:8080/actuator
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: '3.8'
services:

boot-data-window-paginiation:
build: ..
ports:
- "18080:8080"
- "18787:8787"
restart: always
depends_on:
- postgresqldb
environment:
- SPRING_PROFILES_ACTIVE=docker
- SPRING_DATASOURCE_DRIVER_CLASS_NAME=org.postgresql.Driver
- SPRING_DATASOURCE_URL=jdbc:postgresql://postgresqldb:5432/appdb
- SPRING_DATASOURCE_USERNAME=appuser
- SPRING_DATASOURCE_PASSWORD=secret
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: '3.8'
services:

postgresqldb:
image: postgres:16.3-alpine
environment:
- POSTGRES_USER=appuser
- POSTGRES_PASSWORD=secret
- POSTGRES_DB=appdb
ports:
- "5432:5432"

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lombok.addLombokGeneratedAnnotation = true
Loading

0 comments on commit 1570a95

Please sign in to comment.