Migrating from spring data JPA to spring data JDBC
Abstract
To migrate, you better have tests. The speaker suggest using baby-steps and the mikado method to migrate.
- spring data jdbc uses aggregate
- you can choose breadth-first (callers) or depth (migrating the repositories) first when migrating
Steps to migrate (mostly untangling JPA):
- Remove extra repositories.
- Remove
cascade
between aggregates.
- Bidirectional-references → Unidirectional-references.
- ⚠️ spring data JPA is “smart” and save the aggregate when going out of the transaction, i.e. without calling
repository.save
.- Make
M:N
join tables explicit.
- Create an entity for this join.
- Add spring data jdbc.
- Create
Read/Write
converter.- Migrate one aggregate at a time.
Reviews
Why did I want to read/watch this? I’m interested about spring data jdbc.
What did I get out of it? Nothing much, since I’m not planning to do any persistence layer migration anytime soon…