Is it possible to use both Spring Data R2DBC and Spring Data JPA in a single Spring boot application?

前端 未结 1 1619
醉话见心
醉话见心 2021-01-14 16:37

I have an application which is using Spring data JPA and hibernate envers for db auditing. Since R2DBC doesn\'t support auditing yet, is it possible to use combination of b

相关标签:
1条回答
  • 2021-01-14 16:52
    1. Spring provided simple Auditing via @EnableR2dbcAuditing, check my example.

    2. Mix JPA in a reactive application is also possible, I have an example to demo run JPA in a reactive application, but not added r2dbc in it.

    3. For your plan, a better solution is applying the cqrs pattern on the database topology, use database cluster for your application.

      • JPA for applying changes, use the main/master database to accept the modification, and sync changes to the secondary/slave database.
      • r2dbc for queries as you expected, use the secondary/slave database to query.
      • use a gateway at the front for the query and command service.

    Update: I have created a sample to demo JPA and R2dbc coexistence in a single webflux application. But I do not suggest using it in real-world applications. Consider the 3rd solution above if you really need it.

    0 讨论(0)
提交回复
热议问题