- Notifications
You must be signed in to change notification settings - Fork0
Sanne/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, andDb2 aresupported.
Learn more athttp://hibernate.org/reactive.
Hibernate Reactive has been tested with:
- Java 8
- PostgreSQL 13
- MySQL 8
- MariaDB 10
- Db2 11.5
- CockroachDB 20.2
- Hibernate ORM 5.4.29.Final
- Vert.x 3.9.6
- Vert.x Reactive PostgreSQL Client
- Vert.x Reactive MySQL Client
- Vert.x Reactive Db2 Client
- Quarkus via the Hibernate Reactive extension
Support for SQL Server is coming soon.
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!
The directoryexamples
contains several small projects showingdifferent features of Hibernate Reactive:
A list ofquickstarts for Quarkus is available on GitHub:
- Hibernate Reactive with RESTEasy Reactive quickstart
- Hibernate Reactive with Vert.x Web Routes quickstart
Or you cangenerate a new Quarks projectthat uses the Hibernate Reactive extension and start coding right away.
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 compileJava
To publish Hibernate Reactive to your local Maven repository, run:
./gradlew publishToMavenLocal
To build the API and Reference documentation type:
./gradlew assembleDocumentation
You'll find the generated documentation in the subdirectoryrelease/build/documentation
.
open release/build/documentation/reference/html_single/index.htmlopen release/build/documentation/javadocs/index.html
To 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 againstMySQL, MariaDB, or Db2, you must explicitly specify-Pdb=mysql
,-Pdb=maria
, or-Pdb=db2
, for example:
./gradlew test -Pdb=db2
It's also possible to run all tests or only selected tests onall available databases:
./gradlew testAll -PincludeTests=DefaultPortTest
the propertyincludeTests
represents the name of the test to runand can contain the wildcard '*'. The property is optional butrunning all tests on all databases might take a lot of time.
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 -Pdocker
Or:
./gradlew test -Pdocker -Pdb=mysql
Or:
./gradlew test -Pdocker -Pdb=maria
Or:
./gradlew test -Pdocker -Pdb=db2
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;
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-reactive
directory.
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.
- Automatic update or validation of an existing database schema requireuse of JDBC.
- The annotation
@org.hibernate.annotations.Source
fordatabase-generated@Version
properties is not yet supported. - The annotation
@org.hibernate.annotations.CollectionId
is not yetsupported.