Implement equals() and hashCode for composite ID classes.
Change-Id: I7fd6be62f62f8dc43fa2863f52287654d307e8e0
diff --git a/src/main/java/eu/mulk/mulkcms2/entity/ArticleBranchTipPK.java b/src/main/java/eu/mulk/mulkcms2/entity/ArticleBranchTipPK.java
index 2508f87..6472a8d 100644
--- a/src/main/java/eu/mulk/mulkcms2/entity/ArticleBranchTipPK.java
+++ b/src/main/java/eu/mulk/mulkcms2/entity/ArticleBranchTipPK.java
@@ -1,6 +1,7 @@
package eu.mulk.mulkcms2.entity;
import java.io.Serializable;
+import java.util.Objects;
import javax.persistence.Column;
import javax.persistence.Id;
@@ -28,4 +29,21 @@
public void setRevisionId(int revisionId) {
this.revisionId = revisionId;
}
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (!(o instanceof ArticleBranchTipPK)) {
+ return false;
+ }
+ ArticleBranchTipPK that = (ArticleBranchTipPK) o;
+ return articleId == that.articleId && revisionId == that.revisionId;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(articleId, revisionId);
+ }
}
diff --git a/src/main/java/eu/mulk/mulkcms2/entity/ArticleRevisionCharacteristicPK.java b/src/main/java/eu/mulk/mulkcms2/entity/ArticleRevisionCharacteristicPK.java
index 2da588e..edaaff1 100644
--- a/src/main/java/eu/mulk/mulkcms2/entity/ArticleRevisionCharacteristicPK.java
+++ b/src/main/java/eu/mulk/mulkcms2/entity/ArticleRevisionCharacteristicPK.java
@@ -1,6 +1,7 @@
package eu.mulk.mulkcms2.entity;
import java.io.Serializable;
+import java.util.Objects;
import javax.persistence.Id;
public class ArticleRevisionCharacteristicPK implements Serializable {
@@ -24,4 +25,22 @@
public void setArticleRevisionId(int articleRevisionId) {
this.articleRevisionId = articleRevisionId;
}
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (!(o instanceof ArticleRevisionCharacteristicPK)) {
+ return false;
+ }
+ ArticleRevisionCharacteristicPK that = (ArticleRevisionCharacteristicPK) o;
+ return articleRevisionId == that.articleRevisionId
+ && Objects.equals(characteristic, that.characteristic);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(characteristic, articleRevisionId);
+ }
}