From 9d3ee273f6d857e7d56fa131291a093e8096afe4 Mon Sep 17 00:00:00 2001 From: Anton Romanov Date: Mon, 24 Jun 2019 14:53:55 +0400 Subject: [PATCH] fix spring boot version --- build.gradle | 2 +- .../java/ru/ulstu/core/model/BaseEntity.java | 16 +++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/build.gradle b/build.gradle index 959c4a2..4fb0185 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,6 @@ buildscript { ext { - versionSpringBoot = '2.1.3.RELEASE' + versionSpringBoot = '2.1.6.RELEASE' } repositories { diff --git a/src/main/java/ru/ulstu/core/model/BaseEntity.java b/src/main/java/ru/ulstu/core/model/BaseEntity.java index 4a61bb7..a985dcc 100644 --- a/src/main/java/ru/ulstu/core/model/BaseEntity.java +++ b/src/main/java/ru/ulstu/core/model/BaseEntity.java @@ -7,10 +7,9 @@ import javax.persistence.MappedSuperclass; import javax.persistence.Version; import javax.validation.constraints.NotNull; import java.io.Serializable; -import java.util.Objects; @MappedSuperclass -public abstract class BaseEntity implements Serializable, Comparable { +public abstract class BaseEntity implements Serializable, Comparable { @Id @GeneratedValue(strategy = GenerationType.TABLE) private Integer id; @@ -42,7 +41,14 @@ public abstract class BaseEntity implements Serializable, Comparable { return false; } BaseEntity other = (BaseEntity) obj; - return Objects.equals(id, other.id); + if (id == null) { + if (other.id != null) { + return false; + } + } else if (!id.equals(other.id)) { + return false; + } + return true; } @Override @@ -62,8 +68,8 @@ public abstract class BaseEntity implements Serializable, Comparable { } @Override - public int compareTo(@NotNull Object o) { - return id != null ? id.compareTo(((BaseEntity) o).getId()) : -1; + public int compareTo(@NotNull BaseEntity o) { + return id != null ? id.compareTo(o.getId()) : -1; } public void reset() {