From b4c677371328e0094df4deb6cbe28b19fe6edbed Mon Sep 17 00:00:00 2001 From: Nathan Cannon Date: Wed, 19 Sep 2018 14:31:54 +0100 Subject: [PATCH] Added @JsonIdentityInfo. --- .../uk/co/neviyn/Observations/core/Observation.java | 11 ++++++----- .../java/uk/co/neviyn/Observations/core/Site.java | 13 ++++++++----- .../java/uk/co/neviyn/Observations/core/Tutor.java | 3 +++ 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/backend/src/main/java/uk/co/neviyn/Observations/core/Observation.java b/backend/src/main/java/uk/co/neviyn/Observations/core/Observation.java index 872009c..a8e4afd 100644 --- a/backend/src/main/java/uk/co/neviyn/Observations/core/Observation.java +++ b/backend/src/main/java/uk/co/neviyn/Observations/core/Observation.java @@ -1,15 +1,15 @@ package uk.co.neviyn.Observations.core; +import com.fasterxml.jackson.annotation.JsonIdentityInfo; import com.fasterxml.jackson.annotation.JsonProperty; - -import java.io.Serializable; -import java.util.List; -import java.util.Set; - +import com.fasterxml.jackson.annotation.ObjectIdGenerators; import lombok.*; import org.joda.time.DateTime; import javax.persistence.*; +import java.io.Serializable; +import java.util.List; +import java.util.Set; @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) @@ -19,6 +19,7 @@ import javax.persistence.*; @NoArgsConstructor @AllArgsConstructor @Builder +@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "id") public class Observation extends BaseEntity implements Serializable { @JsonProperty diff --git a/backend/src/main/java/uk/co/neviyn/Observations/core/Site.java b/backend/src/main/java/uk/co/neviyn/Observations/core/Site.java index a934f92..5879a05 100644 --- a/backend/src/main/java/uk/co/neviyn/Observations/core/Site.java +++ b/backend/src/main/java/uk/co/neviyn/Observations/core/Site.java @@ -1,13 +1,15 @@ package uk.co.neviyn.Observations.core; +import com.fasterxml.jackson.annotation.JsonIdentityInfo; import com.fasterxml.jackson.annotation.JsonProperty; - -import java.io.Serializable; -import java.util.Set; - +import com.fasterxml.jackson.annotation.ObjectIdGenerators; import lombok.*; -import javax.persistence.*; +import javax.persistence.Entity; +import javax.persistence.OneToMany; +import javax.persistence.Table; +import java.io.Serializable; +import java.util.Set; @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) @@ -16,6 +18,7 @@ import javax.persistence.*; @Data @NoArgsConstructor @RequiredArgsConstructor +@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "id") public class Site extends BaseEntity implements Serializable { @NonNull diff --git a/backend/src/main/java/uk/co/neviyn/Observations/core/Tutor.java b/backend/src/main/java/uk/co/neviyn/Observations/core/Tutor.java index d768655..9a20ffb 100644 --- a/backend/src/main/java/uk/co/neviyn/Observations/core/Tutor.java +++ b/backend/src/main/java/uk/co/neviyn/Observations/core/Tutor.java @@ -1,6 +1,8 @@ package uk.co.neviyn.Observations.core; +import com.fasterxml.jackson.annotation.JsonIdentityInfo; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.ObjectIdGenerators; import lombok.*; import javax.persistence.*; @@ -15,6 +17,7 @@ import java.util.Set; @NoArgsConstructor @AllArgsConstructor @Builder +@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "id") public class Tutor extends BaseEntity implements Serializable { @NonNull