framework-web:spring:relations

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

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] jcheronframework-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 = "author" // ❌ N'est PAS le owner+    @OneToMany(mappedBy = "author" // ❌ Non owner
     private List<Book> books;     private List<Book> books;
 } }
Ligne 536: Ligne 536:
 public class Book { public class Book {
     @ManyToOne     @ManyToOne
-    @JoinColumn(name = "author_id" // ✅ EST le owner+    @JoinColumn(name = "author_id" // ✅ Owner
     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,  -- ← LA CLÉ ÉTRANGÈRE EST ICI !+    author_id BIGINT,
     CONSTRAINT fk_author FOREIGN KEY (author_id) REFERENCES author(id)     CONSTRAINT fk_author FOREIGN KEY (author_id) REFERENCES author(id)
 ); );
  • framework-web/spring/relations.1759878542.txt.gz
  • Dernière modification : il y a 2 mois
  • de jcheron