From dcf3e49cb3e55f1ace2df74a8193a467975b09dc Mon Sep 17 00:00:00 2001 From: jendib Date: Thu, 1 Aug 2013 23:46:02 +0200 Subject: [PATCH] hashCode and equals on embedded entity --- .../docs/core/model/jpa/DocumentTag.java | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/docs-core/src/main/java/com/sismics/docs/core/model/jpa/DocumentTag.java b/docs-core/src/main/java/com/sismics/docs/core/model/jpa/DocumentTag.java index 6d4afd2a..cc8a2b8d 100644 --- a/docs-core/src/main/java/com/sismics/docs/core/model/jpa/DocumentTag.java +++ b/docs-core/src/main/java/com/sismics/docs/core/model/jpa/DocumentTag.java @@ -96,6 +96,44 @@ public class DocumentTag implements Serializable { public void setTagId(String tagId) { this.tagId = tagId; } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((documentId == null) ? 0 : documentId.hashCode()); + result = prime * result + ((tagId == null) ? 0 : tagId.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + DocumentTag other = (DocumentTag) obj; + if (documentId == null) { + if (other.documentId != null) { + return false; + } + } else if (!documentId.equals(other.documentId)) { + return false; + } + if (tagId == null) { + if (other.tagId != null) { + return false; + } + } else if (!tagId.equals(other.tagId)) { + return false; + } + return true; + } @Override public String toString() {