From c6707e5436a99f09673dfad2119f88b05cde69ab Mon Sep 17 00:00:00 2001 From: Pekka Helenius Date: Wed, 23 Sep 2020 01:23:11 +0300 Subject: [PATCH] Hide Id fields from JSON data. Necessary? Signed-off-by: Pekka Helenius --- bookstore/src/main/java/com/fjordtek/bookstore/model/Book.java | 2 ++ .../src/main/java/com/fjordtek/bookstore/model/Category.java | 2 ++ 2 files changed, 4 insertions(+) diff --git a/bookstore/src/main/java/com/fjordtek/bookstore/model/Book.java b/bookstore/src/main/java/com/fjordtek/bookstore/model/Book.java index df6761e..f051aba 100644 --- a/bookstore/src/main/java/com/fjordtek/bookstore/model/Book.java +++ b/bookstore/src/main/java/com/fjordtek/bookstore/model/Book.java @@ -24,6 +24,7 @@ import javax.validation.constraints.NotBlank; import javax.validation.constraints.Pattern; import javax.validation.constraints.Size; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonManagedReference; import com.fjordtek.bookstore.annotation.CurrentYear; @@ -73,6 +74,7 @@ public class Book { name = "bookIdGenerator", sequenceName = "bookIdSequence" ) + @JsonIgnore private Long id; //////////////////// diff --git a/bookstore/src/main/java/com/fjordtek/bookstore/model/Category.java b/bookstore/src/main/java/com/fjordtek/bookstore/model/Category.java index 93dac3a..8d98e78 100644 --- a/bookstore/src/main/java/com/fjordtek/bookstore/model/Category.java +++ b/bookstore/src/main/java/com/fjordtek/bookstore/model/Category.java @@ -12,6 +12,7 @@ import javax.persistence.OneToMany; import javax.persistence.SequenceGenerator; import com.fasterxml.jackson.annotation.JsonBackReference; +import com.fasterxml.jackson.annotation.JsonIgnore; @Entity public class Category { @@ -27,6 +28,7 @@ public class Category { name = "categoryIdGenerator", sequenceName = "categoryIdSequence" ) + @JsonIgnore private Long id; ////////////////////