Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork102
A reactive API for Hibernate ORM, supporting non-blocking database drivers and a reactive style of interaction with the database.
License
hibernate/hibernate-reactive
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
A reactive API forHibernate ORM, supporting non-blocking databasedrivers and a reactive style of interaction with the database.
Hibernate Reactive may be used in any plain Java program, but isespecially targeted toward usage in reactive environments likeQuarkus andVert.x.
CurrentlyPostgreSQL,MySQL,MariaDB,Db2,CockroachDB,MS SQL Server andOracle are supported.
Learn more athttp://hibernate.org/reactive.
Hibernate Reactive has been tested with:
- Java 17, 21, 24
- PostgreSQL 17
- MySQL 9
- MariaDB 11
- Db2 12
- CockroachDB v25
- MS SQL Server 2025
- Oracle 23
- Hibernate ORM 7.1
- Vert.x Reactive PostgreSQL Client 5.0
- Vert.x Reactive MySQL Client 5.0
- Vert.x Reactive Db2 Client 5.0
- Vert.x Reactive MS SQL Server Client 5.0
- Vert.x Reactive Oracle Client 5.0
- Quarkus via the Hibernate Reactive extension
The exact version of the libraries and images are in thecatalogand in thetooling/docker folder.
TheIntroduction to Hibernate Reactive coverseverything you need to know to get started, including:
- setting up a project that uses Hibernate Reactive and theVert.x reactive SQL client for your database,
- configuring Hibernate Reactive to access your database,
- writing Java code todefine the entities of your data model,
- writing reactive data access codeusing a reactive session,and
- tuning the performance of your program.
We recommend you start there!
TheVert.x and Hibernate Reactive How-to explains how to useHibernate Reactive in Vert.x.
TheHibernate Reactive with Panache Guide introducesPanache Reactive, an active record-style API based on Hibernate Reactive.
The directoryexamples contains several small projects showingdifferent features of Hibernate Reactive:
A collection ofquickstarts for Quarkus is available on GitHub:
- Hibernate Reactive with RESTEasy Reactive
- Hibernate Reactive with Panache
- Hibernate Reactive with Vert.x Web Routes
Or you cangenerate a new Quarkus projectthat uses the Hibernate Reactive extension and start coding right away.
WithJBang you can run one of the examples available in the catalogwithout having to clone the repository or setup the project in the IDE.Once you have downloaded JBang, the list of examples is available via:
jbang alias list hibernate/hibernate-reactiveIf you want to run one of the example (in this case the one calledexample), you can do it with:
jbang example@hibernate/hibernate-reactiveor you canopen it in your editor (IntelliJ IDEA in this case) with:
jbang edit --open=idea testcase@hibernate/hibernate-reactiveYou can also generate and run a db-specific test. See available templates using:jbang template list
cockroachdb-reproducer = Template for a test with CockroachDB using Junit 4, Vert.x Unit and Testcontainersdb2-reproducer = Template for a test with Db2 using Junit 4, Vert.x Unit and Testcontainersmariadb-reproducer = Template for a test with MariaDB using Junit 4, Vert.x Unit and Testcontainersmysql-reproducer = Template for a test with MySQL using Junit 4, Vert.x Unit and Testcontainerspg-reproducer = Template for a test with PostgreSQL using Junit 4, Vert.x Unit and TestcontainersExample for PostgreSQL:
- Generate java test from template:
jbang init --template=pg-reproducer pgTest.java - Run the test:
jbang pgTest.java
The project is built with Gradle, but you donot need to have Gradleinstalled on your machine.
To compile this project, navigate to thehibernate-reactive directory,and type:
./gradlew compileJavaTo publish Hibernate Reactive to your local Maven repository, run:
./gradlew publishToMavenLocalTo build the API and Reference documentation type:
./gradlew assembleDocumentationYou'll find the generated documentation in the subdirectoryrelease/build/documentation.
open release/build/documentation/reference/html_single/index.htmlopen release/build/documentation/javadocs/index.htmlTo run the tests, you'll need to decide which RDBMS you want to testwith, and then get an instance of the test database running on yourmachine.
By default, the tests will be run against PostgreSQL. To test againsta different database, you must explicitly specify it using the property-Pdb, as shown in the table below.
| Database | Command |
|---|---|
| PostgreSQL | ./gradlew test -Pdb=pg |
| MySQL | ./gradlew test -Pdb=mysql |
| MariaDB | ./gradlew test -Pdb=maria |
| DB2 | ./gradlew test -Pdb=db2 |
| SQL Server | ./gradlew test -Pdb=mssql |
| Oracle | ./gradlew test -Pdb=oracle |
It's even possible to run all tests or certain selected tests onall available databases:
./gradlew testAll -PincludeTests=DefaultPortTestThe propertyincludeTests specifies the name of the test to runand may contain the wildcard*. This property is optional, butvery useful, since running all tests on all databases might takea lot of time.
To enable logging of the standard output streams, add the property-PshowStandardOutput.
There are three ways to start the test database.
If you have Docker installed, running the tests is really easy. Youdon't need to create the test databases manually. Just type:
./gradlew test -PdockerThe above command will start an instance of PostgreSQL in a Dockercontainer. You may specify a different database using one of thecommands show in the table below.
| Database | Command |
|---|---|
| PostgreSQL | ./gradlew test -Pdocker -Pdb=pg |
| MySQL | ./gradlew test -Pdocker -Pdb=mysql |
| MariaDB | ./gradlew test -Pdocker -Pdb=maria |
| DB2 | ./gradlew test -Pdocker -Pdb=db2 |
| SQL Server | ./gradlew test -Pdocker -Pdb=mssql |
| Oracle | ./gradlew test -Pdocker -Pdb=oracle |
The tests will run faster if you reuse the same containers acrossmultiple test runs. To do this, edit the testcontainers configurationfile.testcontainers.properties in your home directory, adding thelinetestcontainers.reuse.enable=true. (Just create the file if itdoesn't already exist.)
If you already have PostgreSQL installed on your machine, you'll justneed to create the test database. From the command line, type thefollowing commands:
psqlcreate database hreact;create user hreact with password 'hreact';grant all privileges on database hreact to hreact;alter user hreact createdb;Then run./gradlew test from thehibernate-reactive directory.
If you have MySQL installed, you can create the test database usingthe following commands:
mysql -urootcreate database hreact;create user hreact identified by 'hreact';grant all on hreact.* to hreact;Then run./gradlew test -Pdb=mysql from thehibernate-reactivedirectory.
If you havePodman installed, you can start the testdatabase by following the instructions inpodman.md.
We're working hard to support the full feature set of Hibernate ORM.At present several minor limitations remain.
- The annotation
@org.hibernate.annotations.Sourcefordatabase-generated@Versionproperties is not yet supported. - The annotation
@org.hibernate.annotations.CollectionIdis not yetsupported. - With Db2:
- Automatic schema update and validation is not supported.
@Lobannotation is not supported - Seethis issue on the vertx-db2-client
About
A reactive API for Hibernate ORM, supporting non-blocking database drivers and a reactive style of interaction with the database.
Topics
Resources
License
Code of conduct
Contributing
Security policy
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Sponsor this project
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
