From 3d80e342159d70191c961e8796f2d07783a7db06 Mon Sep 17 00:00:00 2001 From: johnniang Date: Thu, 21 Mar 2019 22:07:07 +0800 Subject: [PATCH] Customize PostCategory#equals and PostTag#hashCode --- .../ryanc/halo/model/entity/PostCategory.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/main/java/cc/ryanc/halo/model/entity/PostCategory.java b/src/main/java/cc/ryanc/halo/model/entity/PostCategory.java index 51c01d323..92555fde1 100644 --- a/src/main/java/cc/ryanc/halo/model/entity/PostCategory.java +++ b/src/main/java/cc/ryanc/halo/model/entity/PostCategory.java @@ -9,6 +9,7 @@ import org.hibernate.annotations.Where; import javax.persistence.*; import java.util.Date; +import java.util.Objects; /** * Post category entity. @@ -21,7 +22,6 @@ import java.util.Date; @Where(clause = "deleted = false") @Data @ToString -@EqualsAndHashCode(callSuper = true) public class PostCategory extends BaseEntity { @Id @@ -46,4 +46,19 @@ public class PostCategory extends BaseEntity { super.prePersist(); id = null; } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + if (!super.equals(o)) return false; + PostCategory that = (PostCategory) o; + return categoryId.equals(that.categoryId) && + postId.equals(that.postId); + } + + @Override + public int hashCode() { + return Objects.hash(super.hashCode(), categoryId, postId); + } }