Différences
Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentes Révision précédente Prochaine révision | Révision précédente | ||
| framework-web:spring:relations [2025/10/08 01:09] – jcheron | framework-web:spring:relations [2025/10/08 01:24] (Version actuelle) – [Schéma de base de données] jcheron | ||
|---|---|---|---|
| Ligne 1: | Ligne 1: | ||
| ====== Relations JPA ====== | ====== Relations JPA ====== | ||
| - | ===== Les Types de Relations ===== | + | ===== Types de Relations ===== |
| ==== @OneToMany / @ManyToOne ==== | ==== @OneToMany / @ManyToOne ==== | ||
| Ligne 529: | Ligne 529: | ||
| @Entity | @Entity | ||
| public class Author { | public class Author { | ||
| - | @OneToMany(mappedBy = " | + | @OneToMany(mappedBy = " |
| private List< | private List< | ||
| } | } | ||
| Ligne 536: | Ligne 536: | ||
| public class Book { | public class Book { | ||
| @ManyToOne | @ManyToOne | ||
| - | @JoinColumn(name = " | + | @JoinColumn(name = " |
| private Author author; | private Author author; | ||
| } | } | ||
| Ligne 551: | Ligne 551: | ||
| id BIGINT PRIMARY KEY, | id BIGINT PRIMARY KEY, | ||
| title VARCHAR(255), | title VARCHAR(255), | ||
| - | author_id BIGINT, | + | author_id BIGINT, |
| CONSTRAINT fk_author FOREIGN KEY (author_id) REFERENCES author(id) | CONSTRAINT fk_author FOREIGN KEY (author_id) REFERENCES author(id) | ||
| ); | ); | ||