{"id":20301835,"url":"https://github.com/ochmanskide/quarkus.jpa-example","last_synced_at":"2026-05-05T01:36:11.857Z","repository":{"id":162405158,"uuid":"563991082","full_name":"ochmanskide/quarkus.jpa-example","owner":"ochmanskide","description":"Example Quarkus project with JPA from Panache","archived":false,"fork":false,"pushed_at":"2023-05-06T05:32:01.000Z","size":260,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-14T10:56:40.391Z","etag":null,"topics":["graalvm","graalvm-native-image","gradle","java","jpa","mandrel","panache","panache-entity","quarkus","quarkus-example","quarkus-gradle"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ochmanskide.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-11-09T19:02:53.000Z","updated_at":"2022-11-10T12:14:15.000Z","dependencies_parsed_at":null,"dependency_job_id":"f5a64597-24a9-4924-b4db-8587e9fb530e","html_url":"https://github.com/ochmanskide/quarkus.jpa-example","commit_stats":null,"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ochmanskide%2Fquarkus.jpa-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ochmanskide%2Fquarkus.jpa-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ochmanskide%2Fquarkus.jpa-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ochmanskide%2Fquarkus.jpa-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ochmanskide","download_url":"https://codeload.github.com/ochmanskide/quarkus.jpa-example/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241801192,"owners_count":20022383,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["graalvm","graalvm-native-image","gradle","java","jpa","mandrel","panache","panache-entity","quarkus","quarkus-example","quarkus-gradle"],"created_at":"2024-11-14T16:27:56.650Z","updated_at":"2026-05-05T01:36:06.825Z","avatar_url":"https://github.com/ochmanskide.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Quarkus JPA Example\n\n**Last updated:** Mon Sep 12 09:58:24 CEST 2022  \n**Author:** Lukasz Ochmanski (github@ochmanski.de)  \n\nThis project uses Quarkus, the Supersonic Subatomic Java Framework.  \nIf you want to learn more about Quarkus, please visit its website: https://quarkus.io/ .  \n\n## Table of Contents:\n\n- [1. How to clone:](#1-how-to-clone)\n- [2. Running the application in dev mode](#2-running-the-application-in-dev-mode)\n- [3. Packaging and running the application](#3-packaging-and-running-the-application)\n- [4. Creating a native executable](#4-creating-a-native-executable)\n- [5. how to create a docker image locally:](#5-how-to-create-a-docker-image-locally)\n  - [5.1. running inside another docker image (known as container build)](#51-running-inside-another-docker-image-known-as-container-build)\n  - [5.2. using your own GraalVM](#52-using-your-own-graalvm)\n- [6. How to start with Docker](#6-how-to-start-with-docker)\n- [7. Docker examples](#7-docker-examples)\n  - [7.1. how to run Quarkus from docker container with custom `application.yml` mount](#71-how-to-run-quarkus-from-docker-container-with-custom-applicationyml-mount)\n    - [7.1.1. Sample `application-docker.yml` with a password](#711-sample-application-dockeryml-with-a-password)\n  - [7.2. how to run Quarkus from docker container with custom `application.yml` mount and a password](#72-how-to-run-quarkus-from-docker-container-with-custom-applicationyml-mount-and-a-password)\n    - [7.2.1. Sample `application-docker.yml` without a password](#721-sample-application-dockeryml-without-a-password)\n  - [7.3. how to run Quarkus from docker container without mounting `application.yml`](#73-how-to-run-quarkus-from-docker-container-without-mounting-applicationyml)\n  - [7.4. how to build your own docker image](#74-how-to-build-your-own-docker-image)\n    - [7.4.1. how to run a snapshot](#741-how-to-run-a-snapshot)\n    - [7.4.2. how to open a docker image](#742-how-to-open-a-docker-image)\n    - [7.4.3. Sample `application-docker.yml` with a password](#743-sample-application-dockeryml-with-a-password)\n- [9. How to bump a version?](#9-how-to-bump-a-version)\n  - [9.1. Add a new tag](#91-add-a-new-tag)\n- [10. Related Guides](#10-related-guides)\n- [11. Including resources](#11-including-resources)\n  - [11.1. Including resources](#111-including-resources)\n\u0026nbsp;\n  \n\u0026nbsp;\n  \n## 1. How to clone:\n\n```bash\ngit clone git@github.com:lukaszochmanski/quarkus-jpa-example.git \\\n~/Workspace/de/ochmanski/microservices/quarkus/quarkus-jpa-example\n```\n\u0026nbsp;\n  \n## 2. Running the application in dev mode\n\nYou can run your application in dev mode that enables live coding using:\n\n```bash script\ngradle quarkusDev\n```\n\nalternatively, you may call:\n\n```bash script\nquarkus dev\n```\n\nThe second call will work, if you have Quarkus SDK installed:\n\n```bash\nsdk install quarkus\n```\n\nto test:\n\n```bash script\ncurl -w \"\\n\" http://localhost:8080/hello\ncurl http://localhost:8080/q/health/live\ncurl http://localhost:8080/q/health/ready\n```\n\n\u003e **_NOTE:_**  Quarkus now ships with a Dev UI, which is available in dev mode only at http://localhost:8080/q/dev/.\n\u0026nbsp;\n  \n\u0026nbsp;\n  \n## 3. Packaging and running the application\n\nThe application can be packaged using:\n\n```bash script\ngradle build\n```\n\nIt produces the `quarkus-run.jar` file in the `build/quarkus-app/` directory.  \nBe aware that it’s not an _über-jar_ as the dependencies are copied into the `build/quarkus-app/lib/` directory.\n\nThe application is now runnable using `java -jar build/quarkus-app/quarkus-run.jar`.\n\nIf you want to build an _über-jar_, execute the following command:\n\n```bash script\ngradle build -Dquarkus.package.type=uber-jar\n```\n\nThe application, packaged as an _über-jar_, is now runnable using `java -jar build/*-runner.jar`.\n\u0026nbsp;\n\n\u0026nbsp;\n\n## 4. Creating a native executable\n\nYou can create a native executable using:\n\n```bash script\ngradle build -Dquarkus.package.type=native\n```\n\nOr, if you don't have GraalVM installed, you can run the native executable build in a container using:\n\n```bash script\ngradle build -Dquarkus.package.type=native -Dquarkus.native.container-build=true\n```\n\nYou can then execute your native executable with: `./build/code-with-quarkus-1.0.18-SNAPSHOT-runner`\n\nIf you want to learn more about building native executables, please consult https://quarkus.io/guides/gradle-tooling.\n\u0026nbsp;\n\n\u0026nbsp;\n  \n## 5. how to create a docker image locally:\n\n### 5.1. running inside another docker image (known as container build)\n\nIn this case the default image `quay.io/quarkus/ubi-quarkus-native-image:22.0-java11` will be used.\n\nThis can be changed in `build.gradle` file:\n\n```groovy\nquarkusBuild {\n  nativeArgs {\n    containerBuild = true\n    builderImage = \"quay.io/quarkus/ubi-quarkus-native-image:22.0.0-java11\"\n    containerRuntime = \"docker\"\n  }\n}\n```\n\nor:\n\n```groovy\nquarkusBuild {\n  nativeArgs {\n    containerBuild = true\n    builderImage = \"base/images/red-hat/red-hat-8-5/quay-io/quarkus/quarkus-micro-image:1.0.0\"\n    containerRuntime = \"docker\"\n  }\n}\n```\n\ncommand to execute:\n\n```bash\nGRAALVM_HOME='$HOME/.sdkman/candidates/java/22.1.0.r17-grl'\ngroupId='de/ochmanski/microservices'\nartifactId='quarkus-jpa-example'\nDOCKER_REPOSITORY=\"snapshots\"\ngradle build \\\n    -Dquarkus.package.type=native \\\n    -Dquarkus.native.container-build=true \\\n    -Dquarkus.native.container-runtime=docker \\\n    -Dquarkus.native.java-home=${GRAALVM_HOME} \\\n    -Dquarkus.native.native-image-xmx=7G \\\n    -Dquarkus.jib.always-cache-base-image=true \\\n    -Dquarkus.container-image.builder=jib \\\n    -Dquarkus.container-image.build=true \\\n    -Dquarkus.container-image.push=false \\\n    -Dquarkus.container-image.name=${artifactId} \\\n    -Dquarkus.container-image.group=${DOCKER_REPOSITORY}/${groupId} \\\n    -Dquarkus.container-image.registry=${HOST}\n```\n\n### 5.2. using your own GraalVM\n\nIt is a recommended way of building the project.  \nMain advantage of this method is that it doesn't require docker\ninstallation, and it works fully offline. However, it requires more maintenance, expertise and\ninitial effort, to configure the environment. But you need to do it only once.  \nThis method is faster because it has less virtualization layers, than the `container build method` described in section\n[5.1.](#51-running-inside-another-docker-image-known-as-container-build)\nIt is running directly in your OS, without the Docker service. Therefore, it also consumes less memory, and less CPU.  \nAs everything that is not virtualized, comes with a price.  \nThis solution is not as portable, as the solution presented above\nin [5.1.](#51-running-inside-another-docker-image-known-as-container-build).\n\nAs of writing this document, it only works on Linux platform. If you use Windows, or MacOS, you may face problems.   \nThis option requires you to install `native-image` first:\n\n```bash\nsdk install java java=22.1.0.r17-grl\nGRAALVM_HOME=$HOME/.sdkman/candidates/java/22.1.0.r17-grl\n$GRAALVM_HOME/bin/gu install native-image\nsdk install quarkus\n```\n\nand execute the build:\n\n```bash\nquarkus build --native\n```\n\na similar command for gradle users:\n\n```bash\ngroupId='de/ochmanski/microservices'\nartifactId='quarkus-jpa-example'\nDOCKER_REPOSITORY=\"snapshots\"\ngradle build \\\n    -Dquarkus.package.type=native \\\n    -Dquarkus.native.container-build=false \\\n    -Dquarkus.native.container-runtime=docker \\\n    -Dquarkus.native.java-home=${GRAALVM_HOME} \\\n    -Dquarkus.native.native-image-xmx=7G \\\n    -Dquarkus.jib.always-cache-base-image=true \\\n    -Dquarkus.container-image.builder=jib \\\n    -Dquarkus.container-image.build=true \\\n    -Dquarkus.container-image.push=false \\\n    -Dquarkus.container-image.name=${artifactId} \\\n    -Dquarkus.container-image.group=${DOCKER_REPOSITORY}/${groupId} \\\n    -Dquarkus.container-image.registry=${HOST}\n```\n\nNote that running the command in MacOS or in Windows will result in the following error:\n\n```bash\n\u003e Task :quarkusBuild FAILED\n\nFAILURE: Build failed with an exception.\n\n* What went wrong:\nExecution failed for task ':quarkusBuild'.\n\u003e io.quarkus.builder.BuildException: Build failure: Build failed due to errors\n        [error]: Build step io.quarkus.container.image.jib.deployment.JibProcessor#buildFromNative threw an exception: java.lang.RuntimeException: \n        The native binary produced by the build is not a Linux binary and therefore cannot be used in a Linux container image. \n        Consider adding \"quarkus.native.container-build=true\" to your configuration\n```\n\nThe reason why it doesn't work, is that it can only run inside a true Linux, or inside another docker image.\nIf you try to build it inside a docker container, you will not see this error. This is exactly the case in our CI\nenvironment.  \nWe run our build pipelines inside another Docker container. You may find details in `buildspec.yml` file.\n\n```bash\n-Dquarkus.native.container-build=false\n```\n\u0026nbsp;\n  \n## 6. How to start with Docker\n\nThis option is good for someone that is not a java developer and wants runtime environment quickly.\n\n```bash\ndocker run --rm -p 8080:8080 --name=\"quarkus-jpa-example-1.0.18\"  \\\n-it ../releases/de/ochmanski/microservices/quarkus-jpa-example:1.0.18\n```\n\nHowever, this will probably not work, because the database url is not the same inside a docker container.  \nOne solution is to open the container and install mysql database there.  \nAnother solution is to use the database that already exists on your machine.  \nA third solution would be to connect to our dev database instance.  \nInstruction steps are given in point 7.  \n\u0026nbsp;\n  \n## 7. Docker examples\nBelow, I present a few examples, how running the app can be achieved without installing java.  \n\nRemember, that the running MySQL database, with a working schema is needed first.  \nIn given examples I used: `127.0.0.1:3306/quarkus_jpa_example_v1`  \nIt could be anything you wish, but remember that the `address`, `port` and `schema` must exist and they must match your configuration.  \nSet it up, before you start the Docker container. Otherwise, you will see an error.  \n\n### 7.1. how to run Quarkus from docker container with custom `application.yml` mount\n\n```bash\ncd ~/Workspace/de/ochmanski/microservices/quarkus-jpa-example\ndocker run --rm -p 8080:8080 --name=\"quarkus-jpa-example-1.0.18\" \\\n--mount type=bind,source=$PWD/src/main/resources/application-docker.yml,\\\ntarget=/work/config/application.yml \\\n-it releases/de/ochmanski/microservices/quarkus-jpa-example:1.0.18\n```\n\n#### 7.1.1. Sample `application-docker.yml` with a password\n\n```yaml\ninfo:\n  application:\n    mounted: yes\nquarkus:\n  datasource:\n    jdbc:\n      url: mysql://host.docker.internal:3306/quarkus_jpa_example_v1?serverTimezone=UTC\u0026useLegacyDatetimeCode=false'\n    password: \u003cchangeme\u003e\n  http:\n    cors: true\n    port: 8080\n  swagger-ui:\n    always-include: true\n    path: '/swagger-ui.html'\n  log:\n    level: DEBUG\n```\n\n### 7.2. how to run Quarkus from docker container with custom `application.yml` mount and a password\n\nSometimes, you may want to re-use your local `QUARKUS_DATASOURCE_PASSWORD`. If the value of the variable is already set,\nyou may pass the value directly into the docker container using `-e` flag. In such case, you can remove the password\nfrom `application-docker.yml` file.\n\n```bash\ncd ~/Workspace/de/ochmanski/microservices/quarkus-jpa-example\ndocker run -it --rm -p 8080:8080 --name=\"quarkus-jpa-example-1.0.18\" \\\n--mount type=bind,source=$PWD/src/main/resources/application-docker.yml,\\\ntarget=/work/config/application.yml \\\n-e QUARKUS_DATASOURCE_PASSWORD=$QUARKUS_DATASOURCE_PASSWORD \\\nreleases/de/ochmanski/microservices/quarkus-jpa-example:1.0.18\n```\n\n#### 7.2.1. Sample `application-docker.yml` without a password\n\n```yaml\ninfo:\n  application:\n    mounted: yes\nquarkus:\n  datasource:\n    jdbc:\n      url: mysql://host.docker.internal:3306/quarkus_jpa_example_v1?serverTimezone=UTC\u0026useLegacyDatetimeCode=false\n  http:\n    cors: true\n    port: 8080\n  swagger-ui:\n    always-include: true\n    path: '/swagger-ui.html'\n  log:\n    level: DEBUG\n```\n\n### 7.3. how to run Quarkus from docker container without mounting `application.yml`\n\n```bash\ndocker run --rm -p 8080:8080 --name=\"quarkus-jpa-example-1.0.18\" \\\n-e QUARKUS_DATASOURCE_PASSWORD=$QUARKUS_DATASOURCE_PASSWORD \\\n-it releases/de/ochmanski/microservices/quarkus-jpa-example:1.0.18\n```\n\n\u003e **_NOTE:_** `quarkus.datasource.url` must contain: `jdbc:mysql://host.docker.internal:3306`\n\u003e not `jdbc:mysql://localhost:3306` !  \n\u003e because docker container doesn't connect to your localhost network, the way `gradle quarkusDev` does.  \n\u003e In a docker container `localhost` is not resolved to `127.0.0.1` of your physical machine.\n\n### 7.4. how to build your own docker image\n\nThis is not recommended, but in case you are a DevOp, and you want to open the docker image, and debug it, before\npublishing a final RELEASE, you may create a SNAPSHOT of the image locally, with the following command:\n\n```bash\ngradle jibDockerBuild\n```\n\nPlease note, that the same snapshot will be automatically created by CodeBuild pipeline, so there is no need to create\nit locally, you may simply push the commit into the remote git repository and create the image direcly in the CodeBuild\npipeline. The result will be the same.\n\n#### 7.4.1. how to run a snapshot\n\nlook at the output of the gradle command in the console. Assuming that the created docker image is identified as:\n`1.0.18-SNAPSHOT`, you may run it in the following manner:\n\n```bash\ncd ~/Workspace/de/ochmanski/microservices/quarkus-jpa-example\ndocker run --rm -p 8080:8080 --name=\"quarkus-jpa-example-1.0.18-SNAPSHOT\" \\\n--mount type=bind,source=$PWD/src/main/resources/application-docker.yml,\\\ntarget=/work/config/application.yml \\\n-it snapshots/de/ochmanski/microservices/quarkus-jpa-example:1.0.18-SNAPSHOT\n```\n\n\u003e **_NOTE:_** `quarkus.datasource.url` must contain: `jdbc:mysql://host.docker.internal:3306`\n\u003e not `jdbc:mysql://localhost:3306` !  \n\u003e because docker container doesn't connect to your localhost network, the way `gradle quarkusDev` does.  \n\u003e In a docker container `localhost` is not resolved to `127.0.0.1` of your physical machine.\n\n#### 7.4.2. how to open a docker image\n\nlook at the output of the gradle command in the console. Assuming that the created docker image is identified as:\n`1.0.18-SNAPSHOT`, you may open it in the following manner:\n\n```bash\ncd ~/Workspace/de/ochmanski/microservices/quarkus-jpa-example\ndocker run --rm -ti --privileged --entrypoint /bin/sh --rm -p 8080:8080 --name=\"quarkus-jpa-example-1.0.18-SNAPSHOT\" \\\n--mount type=bind,source=$PWD/src/main/resources/application-docker.yml,\\\ntarget=/work/config/application.yml \\\n-it snapshots/de/ochmanski/microservices/quarkus-jpa-example:1.0.18-SNAPSHOT\n```\n\n#### 7.4.3. Sample `application-docker.yml` with a password\n\n```yaml\ninfo:\n  application:\n    mounted: yes\nquarkus:\n  datasource:\n    jdbc:\n      url:mysql://host.docker.internal:3306/quarkus_jpa_example_v1?serverTimezone=UTC\u0026useLegacyDatetimeCode=false\n    password: \u003cchangeme\u003e\n  http:\n    cors: true\n    port: 8080\n  swagger-ui:\n    always-include: true\n    path: '/swagger-ui.html'\n  log:\n    level: DEBUG\n```\n\u0026nbsp;\n  \n## 9. How to bump a version?\n\n### 9.1. Add a new tag\n\n```bash\ngit bump\n```\n\nor, standard way:\n\n```bash\ngit checkout main\ngit tag -a 1.0.0 -m 'please always add -a flag, which is short for \"annotated\"'\ngit push --follow-tags\n```\n\u0026nbsp;\n  \n## 10. Related Guides\n\nHibernate Validator ([guide](https://quarkus.io/guides/validation)): Validate object properties (field, getter) and\nmethod parameters for your beans (REST, CDI, JPA)  \n\u0026nbsp;\n  \n## 11. Including resources\n\nSupporting native in your application\nGraalVM imposes a number of constraints and making your application a native executable might require a few tweaks.\n\n### 11.1. Including resources\n\nhttps://quarkus.io/guides/writing-native-applications-tips#including-resources  \nhttps://quarkus.io/guides/writing-native-applications-tips#including-resources-2\n\n```properties\nquarkus.native.resources.includes=foo/**,bar/**/*.txt\n```\n  \n## 12. License\n```\nCopyright 2023 Lukasz Ochmanski\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fochmanskide%2Fquarkus.jpa-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fochmanskide%2Fquarkus.jpa-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fochmanskide%2Fquarkus.jpa-example/lists"}