-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Add Jakarta Data quickstart #1516
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
yrodiere
merged 1 commit into
quarkusio:development
from
marko-bekhta:feat/add-jakarta-data-quick-start
Apr 24, 2025
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,5 @@ | ||
| * | ||
| !target/*-runner | ||
| !target/*-runner.jar | ||
| !target/lib/* | ||
| !target/quarkus-app/ |
This file contains hidden or 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,35 @@ | ||
| # Eclipse | ||
| .project | ||
| .classpath | ||
| .settings/ | ||
| bin/ | ||
|
|
||
| # IntelliJ | ||
| .idea | ||
| *.ipr | ||
| *.iml | ||
| *.iws | ||
|
|
||
| # NetBeans | ||
| nb-configuration.xml | ||
|
|
||
| # Visual Studio Code | ||
| .vscode | ||
|
|
||
| # OSX | ||
| .DS_Store | ||
|
|
||
| # Vim | ||
| *.swp | ||
| *.swo | ||
|
|
||
| # patch | ||
| *.orig | ||
| *.rej | ||
|
|
||
| # Maven | ||
| target/ | ||
| pom.xml.tag | ||
| pom.xml.releaseBackup | ||
| pom.xml.versionsBackup | ||
| release.properties |
Binary file not shown.
20 changes: 20 additions & 0 deletions
20
hibernate-orm-jakarta-data-quickstart/.mvn/wrapper/maven-wrapper.properties
This file contains hidden or 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,20 @@ | ||
| # 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=bin | ||
| distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip | ||
| wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.3.2/maven-wrapper-3.3.2.jar |
This file contains hidden or 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,127 @@ | ||
| # Quarkus demo: Hibernate ORM and RESTEasy | ||
|
|
||
| This is a minimal CRUD service exposing a couple of endpoints over REST, | ||
| with a front-end based on Angular so you can play with it from your browser. | ||
|
|
||
| While the code is surprisingly simple, under the hood this is using: | ||
| - [Hibernate Data Repositories (Jakarta Data)](https://hibernate.org/repositories/) to perform the CRUD operations on the database | ||
| - RESTEasy to expose the REST endpoints | ||
| - A PostgreSQL database; see below to run one via Docker | ||
| - ArC, the CDI inspired dependency injection tool with zero overhead | ||
| - The high performance Agroal connection pool | ||
| - All safely coordinated by the Narayana Transaction Manager | ||
|
|
||
| ## Requirements | ||
|
|
||
| To compile and run this demo you will need: | ||
|
|
||
| - JDK 17+ | ||
| - GraalVM | ||
|
|
||
| In addition, you will need either a PostgreSQL database, or Docker to run one. | ||
|
|
||
| ### Configuring GraalVM and JDK 17+ | ||
|
|
||
| Make sure that both the `GRAALVM_HOME` and `JAVA_HOME` environment variables have | ||
| been set, and that a JDK 17+ `java` command is on the path. | ||
|
|
||
| See the [Building a Native Executable guide](https://quarkus.io/guides/building-native-image) | ||
| for help setting up your environment. | ||
|
|
||
| ## Building the demo | ||
|
|
||
| Launch the Maven build on the checked out sources of this demo: | ||
|
|
||
| > ./mvnw package | ||
|
|
||
| ## Running the demo | ||
|
|
||
| ### Live coding with Quarkus | ||
|
|
||
| The Maven Quarkus plugin provides a development mode that supports | ||
| live coding. To try this out: | ||
|
|
||
| > ./mvnw quarkus:dev | ||
|
|
||
| In this mode you can make changes to the code and have the changes immediately applied, by just refreshing your browser. | ||
|
|
||
| Dev Mode automatically starts a Docker container with a Postgres database. This feature is called ["Dev Services"](https://quarkus.io/guides/dev-services). | ||
|
|
||
| To access the database from the terminal, run: | ||
|
|
||
| ```sh | ||
| docker exec -it <container-name> psql -U quarkus | ||
| ``` | ||
|
|
||
| Hot reload works even when modifying your JPA entities or Jakarta Data repositories. | ||
| Try it! Even the database schema will be updated on the fly. | ||
|
|
||
| ### Run Quarkus in JVM mode | ||
|
|
||
| When you're done iterating in developer mode, you can run the application as a | ||
| conventional jar file. | ||
|
|
||
| First compile it: | ||
|
|
||
| > ./mvnw package | ||
|
|
||
| Next, make sure you have a PostgreSQL database running. In production, Quarkus does not start a container for you like it does in Dev Mode. | ||
| To set up a PostgreSQL database with Docker: | ||
|
|
||
| > docker run -it --rm=true --name quarkus_test -e POSTGRES_USER=quarkus_test -e POSTGRES_PASSWORD=quarkus_test -e POSTGRES_DB=quarkus_test -p 5432:5432 postgres:13.3 | ||
|
|
||
| Connection properties for the Agroal datasource are defined in the standard Quarkus configuration file, | ||
| `src/main/resources/application.properties`. | ||
|
|
||
| Then run it: | ||
|
|
||
| > java -jar ./target/quarkus-app/quarkus-run.jar | ||
|
|
||
| Have a look at how fast it boots. | ||
| Or measure total native memory consumption... | ||
|
|
||
| ### Run Quarkus as a native application | ||
|
|
||
| You can also create a native executable from this application without making any | ||
| source code changes. A native executable removes the dependency on the JVM: | ||
| everything needed to run the application on the target platform is included in | ||
| the executable, allowing the application to run with minimal resource overhead. | ||
|
|
||
| Compiling a native executable takes a bit longer, as GraalVM performs additional | ||
| steps to remove unnecessary codepaths. Use the `native` profile to compile a | ||
| native executable: | ||
|
|
||
| > ./mvnw package -Dnative | ||
|
|
||
| After getting a cup of coffee, you'll be able to run this binary directly: | ||
|
|
||
| > ./target/hibernate-orm-jakarta-data-quickstart-1.0.0-SNAPSHOT-runner | ||
|
|
||
| Please brace yourself: don't choke on that fresh cup of coffee you just got. | ||
|
|
||
| Now observe the time it took to boot, and remember: that time was mostly spent to generate the tables in your database and import the initial data. | ||
|
|
||
| Next, maybe you're ready to measure how much memory this service is consuming. | ||
|
|
||
| N.B. This implies all dependencies have been compiled to native; | ||
| that's a whole lot of stuff: from the bytecode enhancements that Hibernate ORM | ||
| applies to your entities, to the lower level essential components such as the PostgreSQL JDBC driver, the Undertow webserver. | ||
|
|
||
| ## See the demo in your browser | ||
|
|
||
| Navigate to: | ||
|
|
||
| <http://localhost:8080/index.html> | ||
|
|
||
| Have fun, and join the team of contributors! | ||
|
|
||
| ## Running the demo in Kubernetes | ||
|
|
||
| This section provides extra information for running both the database and the demo on Kubernetes. | ||
| As well as running the DB on Kubernetes, a service needs to be exposed for the demo to connect to the DB. | ||
|
|
||
| Then, rebuild demo docker image with a system property that points to the DB. | ||
|
|
||
| ```bash | ||
| -Dquarkus.datasource.jdbc.url=jdbc:postgresql://<DB_SERVICE_NAME>/quarkus_test | ||
| ``` |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.