spring-projects / spring-projects/spring-data-relational

Improve strategy for persisting referenced entities [DATAJDBC-210]

Open
#437 5 comments 2 reactions 1 assignee View on GitHub

@schauder is already working on this.

Since Dec 31, 2020.

in: jdbc type: task
Dominant language
Java
Stars
827
Forks
394
PR merge metrics
No merged PRs in 30d

Description

This is an Epic gathering various approaches to improve the writing behaviour of Spring Data JDBC.

If we have an Aggregate Root A referencing entities B on update the following SQL statements get executed:

  • delete all previously referenced Bs
  • update A
  • insert all now referenced Bs

We should improve this in multiple ways:

  1. Use upserts on Bs and only delete those not longer present
  2. Use batched statements for inserts (and updates) This is implemented.
  3. Allow detection of changed Bs. There are various possibilities how to do this
    • have an annotated attribute carrying this information
    • wrap everything in proxies to track this (I really don't like this because I think it's opening a can of worms)
    • one way or the other compare with the version currently in the database. Not sure how to do that, possibly with a JDBC specific API
  4. Use Upsert for batch inserts #493

Also, performancetests would be nice and probably a good first step.

Create separate issues to work on any of these. Use this issue to discuss these and other strategies to improve persisting performance.

Jens Schauder opened this ticket as DATAJDBC-210

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.