simter-reactive-jpa

Simter reactive jpa encapsulation

License

License

MIT
Categories

Categories

React User Interface Web Frameworks
GroupId

GroupId

tech.simter.reactive
ArtifactId

ArtifactId

simter-reactive-jpa
Last Version

Last Version

0.1.0
Release Date

Release Date

Type

Type

jar
Description

Description

simter-reactive-jpa
Simter reactive jpa encapsulation
Project URL

Project URL

https://github.com/simter/simter-reactive-jpa
Project Organization

Project Organization

simter
Source Code Management

Source Code Management

https://github.com/simter/simter-reactive-jpa.git

Download simter-reactive-jpa

How to add to project

<!-- https://jarcasting.com/artifacts/tech.simter.reactive/simter-reactive-jpa/ -->
<dependency>
    <groupId>tech.simter.reactive</groupId>
    <artifactId>simter-reactive-jpa</artifactId>
    <version>0.1.0</version>
</dependency>
// https://jarcasting.com/artifacts/tech.simter.reactive/simter-reactive-jpa/
implementation 'tech.simter.reactive:simter-reactive-jpa:0.1.0'
// https://jarcasting.com/artifacts/tech.simter.reactive/simter-reactive-jpa/
implementation ("tech.simter.reactive:simter-reactive-jpa:0.1.0")
'tech.simter.reactive:simter-reactive-jpa:jar:0.1.0'
<dependency org="tech.simter.reactive" name="simter-reactive-jpa" rev="0.1.0">
  <artifact name="simter-reactive-jpa" type="jar" />
</dependency>
@Grapes(
@Grab(group='tech.simter.reactive', module='simter-reactive-jpa', version='0.1.0')
)
libraryDependencies += "tech.simter.reactive" % "simter-reactive-jpa" % "0.1.0"
[tech.simter.reactive/simter-reactive-jpa "0.1.0"]

Dependencies

compile (3)

Group / Artifact Type Version
javax.persistence : javax.persistence-api jar 2.2
io.projectreactor : reactor-core jar
org.springframework : spring-context jar

test (8)

Group / Artifact Type Version
org.junit.jupiter : junit-jupiter jar
org.springframework.boot : spring-boot-starter-test jar 2.1.6.RELEASE
io.projectreactor : reactor-test jar
com.ninja-squad : springmockk jar 1.1.2
org.springframework : spring-jdbc jar
org.hibernate : hibernate-entitymanager jar 5.4.3.Final
org.hibernate.validator : hibernate-validator jar 6.0.17.Final
com.h2database : h2 jar 1.4.199

Project Modules

There are no modules declared in this project.

simter-reactive-jpa

A reactive jpa encapsulation.

JPA is the abbreviation of Java Persistence API. Its latest specification is JSR-338. It's blocking natively and not compatible with reactive program by default. This module target to build the compatibility between JPA and reactive program. It uses a Reactor Scheduler that diff to reactor main thread to avoid JPA block the reactor main thread. And this scheduler could be customized or just use the default behavior Schedulers.elastic().

Usage

Maven:

<dependency>
  <groupId>tech.simter.reactive</groupId>
  <artifactId>simter-reactive-jpa</artifactId>
  <version>{version}</version>
</dependency>
<dependency>
  <groupId>tech.simter.reactive</groupId>
  <artifactId>simter-reactive-test</artifactId>
  <version>{version}</version>
</dependency>

Java:

import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import reactor.test.test;
import tech.simter.reactive.jpa.ReactiveEntityManager;
import tech.simter.reactive.test.jpa.ReactiveDataJpaTest;

@SpringJUnitConfig(tech.simter.reactive.jpa.ModuleConfiguration.class)
@ReactiveDataJpaTest
public class TheTest {
  @Autowired
  private ReactiveEntityManager rem;

  @Test
  public test() {
    // save
    MyPo po = new MyPo();
    StepVerifier.create(rem.persist(po))
      .expectNext(po).verifyComplete();

    // find one
    StepVerifier.create(
      rem.createQuery("select t from MyPo t where id = :id", MyPo.class)
      .setParameter("id", 123)
      .getSingleResult()
    ).expectNext(po).verifyComplete();

    // find list
    StepVerifier.create(
      rem.createQuery("select t from MyPo t", MyPo.class)
      .getResultList()
    ).expectNext(po).verifyComplete();
  }
}

@ReactiveDataJpaTest comes from simter-reactive-test.

tech.simter.reactive

Versions

Version
0.1.0