All Projects
Backend

Hospital Domain — Spring Data JPA Relations

A Spring Data JPA modeling study on a hospital domain: Patient, Medecin, RendezVous and Consultation entities wired with @OneToMany, @ManyToOne and @OneToOne, a transactional service layer, derived repositories and a REST endpoint.

4
Entities
3
Relation types
Hibernate
ORM
@Transactional
Service layer
Approach

Model a healthcare domain with bidirectional JPA relations behind a transactional service layer

Tech Stack
Java 17Spring Boot 3.2Spring Data JPAHibernateMySQLH2Maven
Keywords
Spring Data JPAHibernateJPA RelationsEntity ModelingSpring BootMySQL
Deep Dive

A focused study of JPA relationship mapping on a healthcare domain — the data-modeling foundation behind the hospital web apps.

Data model

Patient 1 ───< RendezVous >─── 1 Medecin
                  │ 1
                  ▼ 1
            Consultation
EntityDescriptionRelations
Patientname, date of birth, sick flag@OneToMany → RendezVous
Medecinname, email, specialty@OneToMany → RendezVous
RendezVousdate, status@ManyToOne Patient & Medecin, @OneToOne Consultation
Consultationdate, report@OneToOne RendezVous
StatusRDVenum: PENDING / CANCELED / DONE

Layered architecture

Web (REST controllers) → Service (@Transactional) → Repositories (Spring Data JPA) → Entities

Demonstrates bidirectional associations, an enum-typed status, derived-query repositories and a GET /patients endpoint. Runs on :8087 with MySQL (auto-creates hospital-db); H2 for tests.