From 99610305b6502149a4edb8e7f9a56d357e5b83ef Mon Sep 17 00:00:00 2001 From: neviyn Date: Wed, 12 May 2021 15:48:51 +0100 Subject: [PATCH] Added equals and hashcode override for Member entity --- src/main/kotlin/uk/co/neviyn/booru/Entity.kt | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/uk/co/neviyn/booru/Entity.kt b/src/main/kotlin/uk/co/neviyn/booru/Entity.kt index e0743c9..ed48862 100644 --- a/src/main/kotlin/uk/co/neviyn/booru/Entity.kt +++ b/src/main/kotlin/uk/co/neviyn/booru/Entity.kt @@ -41,7 +41,22 @@ open class Member( @SequenceGenerator(name="member_id_seq", sequenceName = "member_id_seq", allocationSize = 1) @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "member_id_seq") open var id: Long = -1 -) +) { + override fun equals(other: Any?): Boolean { + if(other === this) return true + return if(other is Member){ + other.id == id + } else false + } + + override fun hashCode(): Int { + var result = name.hashCode() + result = 31 * result + email.hashCode() + result = 31 * result + password.hashCode() + result = 31 * result + id.hashCode() + return result + } +} @Entity open class Role(