From 70c56924d7516b8c5e2a30f0edb755e2140bbffc Mon Sep 17 00:00:00 2001 From: "Cai.Willis" Date: Thu, 2 Jan 2025 14:13:43 +0000 Subject: [PATCH] fix: prevent circular serialization in self-referencing classes NO_TICKET: --- tcs-persistence/pom.xml | 2 +- .../com/transformuk/hee/tis/tcs/service/model/Placement.java | 2 ++ .../java/com/transformuk/hee/tis/tcs/service/model/Post.java | 2 ++ tcs-service/pom.xml | 2 +- 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/tcs-persistence/pom.xml b/tcs-persistence/pom.xml index 30ba7cecc..6ac7cdade 100644 --- a/tcs-persistence/pom.xml +++ b/tcs-persistence/pom.xml @@ -13,7 +13,7 @@ A module containing the model and persistence layer for TCS uk.nhs.tis tcs-persistence - 2.32.4 + 2.32.5 com.transformuk.hee.tis diff --git a/tcs-persistence/src/main/java/com/transformuk/hee/tis/tcs/service/model/Placement.java b/tcs-persistence/src/main/java/com/transformuk/hee/tis/tcs/service/model/Placement.java index c38252ea5..49c7dcc5b 100644 --- a/tcs-persistence/src/main/java/com/transformuk/hee/tis/tcs/service/model/Placement.java +++ b/tcs-persistence/src/main/java/com/transformuk/hee/tis/tcs/service/model/Placement.java @@ -1,5 +1,6 @@ package com.transformuk.hee.tis.tcs.service.model; +import com.fasterxml.jackson.annotation.JsonManagedReference; import com.transformuk.hee.tis.tcs.api.dto.PlacementSummaryDTO; import com.transformuk.hee.tis.tcs.api.enumeration.LifecycleState; import com.transformuk.hee.tis.tcs.api.enumeration.Status; @@ -68,6 +69,7 @@ public class Placement implements Serializable { private String intrepidId; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "postId") + @JsonManagedReference private Post post; //Please use site id, site codes from intrepid are NOT unique @Column(name = "siteCode") diff --git a/tcs-persistence/src/main/java/com/transformuk/hee/tis/tcs/service/model/Post.java b/tcs-persistence/src/main/java/com/transformuk/hee/tis/tcs/service/model/Post.java index 11555bd69..65559f637 100644 --- a/tcs-persistence/src/main/java/com/transformuk/hee/tis/tcs/service/model/Post.java +++ b/tcs-persistence/src/main/java/com/transformuk/hee/tis/tcs/service/model/Post.java @@ -1,5 +1,6 @@ package com.transformuk.hee.tis.tcs.service.model; +import com.fasterxml.jackson.annotation.JsonBackReference; import com.transformuk.hee.tis.tcs.api.enumeration.PostSuffix; import com.transformuk.hee.tis.tcs.api.enumeration.Status; import java.io.Serializable; @@ -87,6 +88,7 @@ public class Post implements Serializable { @OneToMany(mappedBy = "post", cascade = CascadeType.ALL, fetch = FetchType.LAZY) private Set fundings = new HashSet<>(); @OneToMany(mappedBy = "post", fetch = FetchType.LAZY) + @JsonBackReference private Set placementHistory = new HashSet<>(); @OneToMany(mappedBy = "post", fetch = FetchType.LAZY) private Set associatedTrusts; diff --git a/tcs-service/pom.xml b/tcs-service/pom.xml index 59f07e2cf..18af7a9f5 100644 --- a/tcs-service/pom.xml +++ b/tcs-service/pom.xml @@ -80,7 +80,7 @@ uk.nhs.tis tcs-persistence - 2.32.4 + 2.32.5 com.zaxxer