Skip to content

IBM/reactive-components

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

reactive-components

Java reactive components

reactive-jpa

DEPRECATED!!! PLEASE REVIEW https://hibernate.org/reactive/

Library that provide a wrapper for JDBC (Blocking API) with reactive components (Project Reactor) using Java Persistent API (Hibernate).

How to use

Install

Maven

  <repositories>
    ...
    <repository>
      <id>snapshots-repo</id>
      <url>https://oss.sonatype.org/content/repositories/snapshots</url>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
    </repository>
    ...
  </repositories>

  <dependencies>
    ...
    <dependency>
      <groupId>com.ibm.reactivecomponents</groupId>
      <artifactId>reactive-jpa</artifactId>
      <version>0.0.1-SNAPSHOT</version>
    </dependency>
    ...
  </dependencies>

Gradle

repositories {
    ...
    maven {
        url 'https://oss.sonatype.org/content/groups/staging'
    }
    ...
}
dependencies {
    ...
    compile('com.ibm.reactivecomponents:reactive-jpa:0.0.1-SNAPSHOT')
    ...
}

Initialize

Map<String, String> settings = new HashMap<>();
settings.put("hibernate.connection.driver_class", "org.hsqldb.jdbcDriver");
settings.put("hibernate.connection.url", "jdbc:hsqldb:mem:test");
settings.put("hibernate.connection.username", "sa");
settings.put("hibernate.show_sql", "true");
settings.put("hibernate.dialect", "org.hibernate.dialect.HSQLDialect");
settings.put("hibernate.hbm2ddl.auto", "update");

List<String> packages = new ArrayList<>(1);
packages.add(Person.class.getPackage().getName()); // list of java packages with Entities
Database database = new Database(settings, packages);

Transaction

Person p1 = new Person("Person 1");
Person p2 = new Person("Person 2");
Mono<Person> mono = database
    .execute(entityManager -> {
      entityManager.persist(p1);
      entityManager.persist(p2);
      return p1;
    })
    .transaction(
        TransactionDefinition
            .builder()
            .isolation(IsolationLevel.SERIALIZABLE)
            .timeout(5)
            .build()
    )
    .mono();

Stream - Hibernate ScrollableResults

Flux<Person> result = database
        .stream("from PERSON person", Person.class)
        .fetchSize(10)
        .maxResults(100)
        .firstResult(1)
        .isolationLevel(IsolationLevel.READ_COMMITTED)
        .flux();

Build Status codecov

About

Library that provide a wrapper for JDBC (Blocking API) with reactive components (Project Reactor) using Java Persistent API (Hibernate).

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages