Skip to main content

Database per Service in Practice: Spring Data JPA, Hibernate, Migrations and Sharding

Learn Database per Service in Practice: Spring Data JPA, Hibernate, Migrations and Sharding (Phase 7 · Database and Transactions (Core), Microservices) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.

Spring Data JPA and Hibernate per service • Each service has its own schema/database , its own entities and repositories, and its own migrations. Use Spring Data JPA + Hibernate for aggregates, with the practices from the Hibernate course: LAZY associations, DTO projections, open-in-view=false , short transactions, @Version optimistic locking, batch fetching and query-count tests. • No foreign keys across services : reference other aggregates by id ( UUID courseId ), not by entity association; integrity is eventual and enforced by events/sagas. Keep aggregates small (one transaction per...

More lessons in Phase 7 · Database and Transactions (Core)