From 4993d46ddad58c528bcfdff68e41fe8c5ca17547 Mon Sep 17 00:00:00 2001 From: pierre-maraval Date: Thu, 12 Dec 2024 08:42:05 +0100 Subject: [PATCH] FIX : Ajout contraintes vers journal et lignefichier dans entity pour suppression en cascade --- .../abes/item/core/entities/item/DemandeExemp.java | 6 +++--- .../abes/item/core/entities/item/DemandeRecouv.java | 12 ++++++++---- .../fr/abes/item/core/entities/item/DemandeSupp.java | 3 +++ 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/core/src/main/java/fr/abes/item/core/entities/item/DemandeExemp.java b/core/src/main/java/fr/abes/item/core/entities/item/DemandeExemp.java index 4daf8576..27f58f14 100644 --- a/core/src/main/java/fr/abes/item/core/entities/item/DemandeExemp.java +++ b/core/src/main/java/fr/abes/item/core/entities/item/DemandeExemp.java @@ -24,9 +24,6 @@ public class DemandeExemp extends Demande{ @Column(name = "LISTE_ZONES", length = 2000) private String listeZones; - @OneToMany(mappedBy = "demandeExemp", fetch = FetchType.LAZY, cascade = CascadeType.REMOVE) - private Set journalDemandes; - @ManyToOne(fetch = FetchType.EAGER) @JoinColumn(name = "DEM_INDEX_RECHERCHE") private IndexRecherche indexRecherche; @@ -34,6 +31,9 @@ public class DemandeExemp extends Demande{ @OneToMany(mappedBy = "demandeExemp", fetch = FetchType.LAZY, cascade = CascadeType.REMOVE) private Set ligneFichierExemps; + @OneToMany(mappedBy = "demandeExemp", fetch = FetchType.LAZY, cascade = CascadeType.REMOVE) + private Set journalDemandes; + public DemandeExemp(Integer numDemande) { super(numDemande); } diff --git a/core/src/main/java/fr/abes/item/core/entities/item/DemandeRecouv.java b/core/src/main/java/fr/abes/item/core/entities/item/DemandeRecouv.java index 3ab1084a..6d25c454 100644 --- a/core/src/main/java/fr/abes/item/core/entities/item/DemandeRecouv.java +++ b/core/src/main/java/fr/abes/item/core/entities/item/DemandeRecouv.java @@ -1,16 +1,14 @@ package fr.abes.item.core.entities.item; import fr.abes.item.core.constant.TYPE_DEMANDE; -import jakarta.persistence.Entity; -import jakarta.persistence.JoinColumn; -import jakarta.persistence.ManyToOne; -import jakarta.persistence.Table; +import jakarta.persistence.*; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; import javax.validation.constraints.NotNull; import java.util.Date; +import java.util.Set; @Entity @Table(name = "DEMANDE_RECOUV") @@ -21,6 +19,12 @@ public class DemandeRecouv extends Demande { @JoinColumn(name = "DEM_INDEX_RECHERCHE") private IndexRecherche indexRecherche; + @OneToMany(mappedBy = "demandeRecouv", fetch = FetchType.LAZY, cascade = CascadeType.REMOVE) + private Set ligneFichierRecouvs; + + @Getter @Setter @OneToMany(mappedBy = "demandeRecouv", fetch = FetchType.LAZY, cascade = CascadeType.REMOVE) + private Set journalDemandeRecouvs; + public DemandeRecouv(@NotNull String rcr, Date dateCreation, Date dateModification, @NotNull EtatDemande etatDemande, String commentaire, Utilisateur utilisateur, IndexRecherche indexRecherche) { super(rcr, dateCreation, dateModification, etatDemande, commentaire, utilisateur); this.indexRecherche = indexRecherche; diff --git a/core/src/main/java/fr/abes/item/core/entities/item/DemandeSupp.java b/core/src/main/java/fr/abes/item/core/entities/item/DemandeSupp.java index 5b703f34..dd478c87 100644 --- a/core/src/main/java/fr/abes/item/core/entities/item/DemandeSupp.java +++ b/core/src/main/java/fr/abes/item/core/entities/item/DemandeSupp.java @@ -34,6 +34,9 @@ public TYPE_DEMANDE getTypeDemande() { @Getter @Setter @OneToMany(mappedBy = "demandeSupp", fetch = FetchType.LAZY, cascade = CascadeType.REMOVE) private Set ligneFichierSupps; + @Getter @Setter @OneToMany(mappedBy = "demandeSupp", fetch = FetchType.LAZY, cascade = CascadeType.REMOVE) + private Set journalDemandeSupps; + public DemandeSupp(String rcr, Date dateCreation, Date dateModification, TYPE_SUPPRESSION typeSuppression, String comment, EtatDemande etatDemande, Utilisateur utilisateur) { super(rcr, dateCreation, dateModification, etatDemande, comment, utilisateur);