3

I am trying to use reactive repositories with H2 using Spring Boot.

I have added dependencies

implementation 'org.springframework.boot.experimental:spring-boot-starter-data-r2dbc:0.1.0.M1'
implementation 'org.springframework.boot.experimental:spring-boot-actuator-autoconfigure-r2dbc:0.1.0.M1'
implementation 'io.r2dbc:r2dbc-pool:0.8.0.RELEASE'

My domains looked like this

@Entity
@Table(name = "json_comparison")
public class JsonComparisonResult {
    @Column(name = "comparison_id")
    @Id
    private String comparisonId;
    @Column(name = "left")
    private String leftSide;
    ....

When the dependency was to

implementation "org.springframework.boot:spring-boot-starter-data-jpa:$springBootVersion"

Everything worked fine. But since I have added r2dbc dependencies it wasn't able to find any dependencies for javax.persistence annotations. When I use starter-jpa with reactive repositories it fails on startup (regular Reactive Repositories are not supported by JPA).

How to solve the problem? Add javax.persistence dependency manually?

What is the problem?

lapots
  • 12,553
  • 32
  • 121
  • 242
  • But it says: "Reactive Repositories are not supported by JPA"!? JPA is not supported because it's not reactive – Simon Martinelli Dec 24 '19 at 12:31
  • I know. The problem is how to fix it as JPA provides a lot annotations. So far I decided to use annotations from `data.relational.core.mapping` and `data.annotation.Id` from spring framework libraries. But stuff like `Enumerated` doesn't have alternatives – lapots Dec 24 '19 at 12:33
  • So you have to wait until JPA becomes reactive as well... – Simon Martinelli Dec 24 '19 at 12:55
  • @SimonMartinelli I will just play around with what exists now. Not for production of course. – lapots Dec 24 '19 at 12:56

1 Answers1

3

As a solution, I decided to switch to org.springframework.data.relational.core.mapping annotations like @Table, @Column and org.springframework.data.annotation @Id.

import org.springframework.data.annotation.Id;
import org.springframework.data.relational.core.mapping.Column;
import org.springframework.data.relational.core.mapping.Table;

In addition, I had to create tables manually via SQL scripts.

lapots
  • 12,553
  • 32
  • 121
  • 242
  • 2
    I am also facing the same issue. How do we resolve the issue for classes Entity, JoinColumn, ManyToOne etc? Which dependency should we use? – Saud Aug 19 '20 at 16:34