-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat : initial commit of jooq-jpa integration (#1613)
* feat : initial commit of jooq-jpa integration * feat : implement code review comments * implement code review comments * implement code review comments
- Loading branch information
1 parent
f216c4b
commit d893c52
Showing
34 changed files
with
1,805 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
*.xml text eol=lf | ||
*.yaml text eol=lf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: boot-jpa-jooq-sample | ||
|
||
on: | ||
push: | ||
paths: | ||
- "jpa/boot-jpa-jooq-sample/**" | ||
branches: [main] | ||
pull_request: | ||
paths: | ||
- "jpa/boot-jpa-jooq-sample/**" | ||
types: | ||
- opened | ||
- synchronize | ||
- reopened | ||
|
||
jobs: | ||
build: | ||
name: Run Unit & Integration Tests | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
working-directory: "jpa/boot-jpa-jooq-sample" | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
jpa/boot-jpa-jooq-sample/.mvn/wrapper/maven-wrapper.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.9/apache-maven-3.9.9-bin.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
FROM eclipse-temurin:21.0.5_11-jre-alpine as builder | ||
WORKDIR /app | ||
ARG JAR_FILE=target/boot-jpa-jooq-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:21.0.5_11-jre-alpine | ||
LABEL maintainer="rajadilipkolli" \ | ||
description="Spring Boot application with JPA and jOOQ integration" \ | ||
version="0.0.1-SNAPSHOT" | ||
WORKDIR /app | ||
COPY --from=builder application/dependencies/ ./ | ||
COPY --from=builder application/spring-boot-loader/ ./ | ||
COPY --from=builder application/snapshot-dependencies/ ./ | ||
COPY --from=builder application/application/ ./ | ||
ARG MAX_RAM_PERCENTAGE=75.0 | ||
ARG INITIAL_RAM_PERCENTAGE=50.0 | ||
ENV JAVA_OPTS="-XX:MaxRAMPercentage=${MAX_RAM_PERCENTAGE} -XX:InitialRAMPercentage=${INITIAL_RAM_PERCENTAGE}" | ||
ENTRYPOINT ["sh", "-c", "java ${JAVA_OPTS} org.springframework.boot.loader.launch.JarLauncher"] | ||
|
||
HEALTHCHECK --interval=30s --timeout=3s \ | ||
CMD wget --quiet --tries=1 --spider http://localhost:8080/actuator/health || exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# boot-jpa-jooq-sample | ||
|
||
This project demonstrates the integration of JPA and jOOQ within a Spring Boot application. | ||
|
||
### Format code | ||
|
||
This project uses Spotless to maintain consistent code formatting. Run the following command to format all files: | ||
|
||
```shell | ||
./mvnw spotless:apply | ||
``` | ||
|
||
### Run tests | ||
|
||
```shell | ||
./mvnw clean verify | ||
``` | ||
|
||
### Run locally | ||
|
||
Ensure you have Docker and Maven installed. Then: | ||
|
||
1. Start the required PostgreSQL database: | ||
|
||
```shell | ||
docker-compose -f docker/docker-compose.yml up -d | ||
``` | ||
|
||
2. Run the application with the local profile (uses local database): | ||
|
||
```shell | ||
./mvnw spring-boot:run -Dspring-boot.run.profiles=local | ||
``` | ||
|
||
### Using Testcontainers at Development Time | ||
|
||
Testcontainers provides isolated, throwaway instances of the PostgreSQL database for testing. | ||
This allows you to run the application without setting up a local database. | ||
|
||
There are two ways to run the application with Testcontainers: | ||
|
||
You can run `TestJpaJooqApplication.java` from your IDE directly. | ||
Alternatively, use Maven: | ||
|
||
```shell | ||
./mvnw spring-boot:test-run | ||
``` | ||
|
||
|
||
### Useful Links | ||
* [Swagger UI](http://localhost:8080/swagger-ui.html) - API documentation and testing interface | ||
* [Actuator Endpoints](http://localhost:8080/actuator) - Application monitoring and management |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
POSTGRES_DB=appdb | ||
POSTGRES_USER=appuser | ||
POSTGRES_PASSWORD=secret |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
version: '3.8' | ||
services: | ||
|
||
boot-jpa-jooq-sample: | ||
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/${POSTGRES_DB} | ||
- SPRING_DATASOURCE_USERNAME=${POSTGRES_USER} | ||
- SPRING_DATASOURCE_PASSWORD=${POSTGRES_PASSWORD} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
version: '3.8' | ||
services: | ||
|
||
postgresqldb: | ||
image: postgres:17.2-alpine | ||
hostname: postgresqldb | ||
extra_hosts: [ 'host.docker.internal:host-gateway' ] | ||
environment: | ||
- POSTGRES_USER=appuser | ||
- POSTGRES_PASSWORD=secret | ||
- POSTGRES_DB=appdb | ||
healthcheck: | ||
test: ["CMD-SHELL", "pg_isready -U appuser -d appdb"] | ||
interval: 10s | ||
timeout: 5s | ||
retries: 5 | ||
ports: | ||
- "5432:5432" | ||
networks: | ||
- demo-network | ||
|
||
pgadmin: | ||
image: dpage/pgadmin4 | ||
extra_hosts: [ 'host.docker.internal:host-gateway' ] | ||
environment: | ||
- [email protected] | ||
- PGADMIN_DEFAULT_PASSWORD=admin | ||
- PGADMIN_CONFIG_SERVER_MODE=False | ||
- PGADMIN_CONFIG_MASTER_PASSWORD_REQUIRED=False | ||
ports: | ||
- "5050:80" | ||
depends_on: | ||
postgresqldb: | ||
condition: service_started | ||
volumes: | ||
- ./docker_pgadmin_servers.json:/pgadmin4/servers.json | ||
entrypoint: | ||
- "/bin/sh" | ||
- "-c" | ||
- "/bin/echo 'postgresqldb:5432:*:appuser:secret' > /tmp/pgpassfile && chmod 600 /tmp/pgpassfile && /entrypoint.sh" | ||
restart: unless-stopped | ||
networks: | ||
- demo-network | ||
|
||
|
||
networks: | ||
demo-network: | ||
driver: bridge |
14 changes: 14 additions & 0 deletions
14
jpa/boot-jpa-jooq-sample/docker/docker_pgadmin_servers.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"Servers": { | ||
"1": { | ||
"Name": "Docker Compose DB", | ||
"Group": "Servers", | ||
"Port": 5432, | ||
"Username": "appuser", | ||
"Host": "postgresqldb", | ||
"SSLMode": "prefer", | ||
"MaintenanceDB": "appdb", | ||
"PassFile": "/tmp/pgpassfile" | ||
} | ||
} | ||
} |
Oops, something went wrong.