项目作者: hibernate

项目描述 :
A reactive API for Hibernate ORM, supporting non-blocking database drivers and a reactive style of interaction with the database.
高级语言: Java
项目地址: git://github.com/hibernate/hibernate-reactive.git
创建时间: 2019-01-25T14:28:07Z
项目社区:https://github.com/hibernate/hibernate-reactive

开源协议:GNU Lesser General Public License v2.1

下载


Hibernate team logo

Main branch build status
Apache 2.0 license
Latest version on Maven Central
Developers stream on Zulip
Hibernate Reactive documentation
Reproducible Builds

Hibernate Reactive

A reactive API for Hibernate ORM, supporting non-blocking database
drivers and a reactive style of interaction with the database.

Hibernate Reactive may be used in any plain Java program, but is
especially targeted toward usage in reactive environments like
Quarkus and Vert.x.

Currently PostgreSQL, MySQL, MariaDB, Db2,
CockroachDB, MS SQL Server and Oracle are supported.

Learn more at http://hibernate.org/reactive.

Compatibility

Hibernate Reactive has been tested with:

Documentation

The Introduction to Hibernate Reactive covers
everything you need to know to get started, including:

We recommend you start there!

The Vert.x and Hibernate Reactive How-to explains how to use
Hibernate Reactive in Vert.x.

The Hibernate Reactive with Panache Guide introduces
Panache Reactive, an active record-style API based on Hibernate Reactive.

Examples

The directory examples contains several small projects showing
different features of Hibernate Reactive:

Quarkus quickstarts

A collection of quickstarts for Quarkus is available on GitHub:

Or you can generate a new Quarkus project
that uses the Hibernate Reactive extension and start coding right away.

Examples using JBang

With JBang you can run one of the examples available in the catalog
without having to clone the repository or setup the project in the IDE.
Once you have downloaded JBang, the list of examples is available via:

  1. jbang alias list hibernate/hibernate-reactive

If you want to run one of the example (in this case the one called example), you can do it with:

  1. jbang example@hibernate/hibernate-reactive

or you can open it in your editor (IntelliJ IDEA in this case) with:

  1. jbang edit --open=idea testcase@hibernate/hibernate-reactive

You can also generate and run a db-specific test. See available templates using: jbang template list

  1. cockroachdb-reproducer = Template for a test with CockroachDB using Junit 4, Vert.x Unit and Testcontainers
  2. db2-reproducer = Template for a test with Db2 using Junit 4, Vert.x Unit and Testcontainers
  3. mariadb-reproducer = Template for a test with MariaDB using Junit 4, Vert.x Unit and Testcontainers
  4. mysql-reproducer = Template for a test with MySQL using Junit 4, Vert.x Unit and Testcontainers
  5. pg-reproducer = Template for a test with PostgreSQL using Junit 4, Vert.x Unit and Testcontainers

Example for PostgreSQL:

  • Generate java test from template: jbang init --template=pg-reproducer pgTest.java
  • Run the test: jbang pgTest.java

Gradle build

The project is built with Gradle, but you do not need to have Gradle
installed on your machine.

Building

To compile this project, navigate to the hibernate-reactive directory,
and type:

  1. ./gradlew compileJava

To publish Hibernate Reactive to your local Maven repository, run:

  1. ./gradlew publishToMavenLocal

Building documentation

To build the API and Reference documentation type:

  1. ./gradlew assembleDocumentation

You’ll find the generated documentation in the subdirectory
release/build/documentation.

  1. open release/build/documentation/reference/html_single/index.html
  2. open release/build/documentation/javadocs/index.html

Running tests

To run the tests, you’ll need to decide which RDBMS you want to test
with, and then get an instance of the test database running on your
machine.

By default, the tests will be run against PostgreSQL. To test against
a 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 on
all available databases:

  1. ./gradlew testAll -PincludeTests=DefaultPortTest

The property includeTests specifies the name of the test to run
and may contain the wildcard *. This property is optional, but
very useful, since running all tests on all databases might take
a 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

If you have Docker installed, running the tests is really easy. You
don’t need to create the test databases manually. Just type:

  1. ./gradlew test -Pdocker

The above command will start an instance of PostgreSQL in a Docker
container. You may specify a different database using one of the
commands 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 across
multiple test runs. To do this, edit the testcontainers configuration
file .testcontainers.properties in your home directory, adding the
line testcontainers.reuse.enable=true. (Just create the file if it
doesn’t already exist.)

If you already have PostgreSQL installed

If you already have PostgreSQL installed on your machine, you’ll just
need to create the test database. From the command line, type the
following commands:

  1. psql
  2. create database hreact;
  3. create user hreact with password 'hreact';
  4. grant all privileges on database hreact to hreact;
  5. alter user hreact createdb;

Then run ./gradlew test from the hibernate-reactive directory.

If you already have MySQL installed

If you have MySQL installed, you can create the test database using
the following commands:

  1. mysql -uroot
  2. create database hreact;
  3. create user hreact identified by 'hreact';
  4. grant all on hreact.* to hreact;

Then run ./gradlew test -Pdb=mysql from the hibernate-reactive
directory.

If you have Podman

If you have Podman installed, you can start the test
database by following the instructions in podman.md.

Limitations

We’re working hard to support the full feature set of Hibernate ORM.
At present several minor limitations remain.