Skip to content

Commit

Permalink
Use ProxyUtils in equals methods for entities
Browse files Browse the repository at this point in the history
  • Loading branch information
romanstrobl committed Jun 3, 2024
1 parent 48344e4 commit 7373d62
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import jakarta.persistence.*;
import lombok.Getter;
import lombok.Setter;
import org.springframework.data.util.ProxyUtils;

import java.io.Serial;
import java.io.Serializable;
Expand Down Expand Up @@ -69,7 +70,7 @@ public class AttachmentEntity implements Serializable {
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (o == null || !this.getClass().equals(ProxyUtils.getUserClass(o))) return false;
AttachmentEntity that = (AttachmentEntity) o;
return document.equals(that.document) && attachmentType.equals(that.attachmentType) && timestampCreated.equals(that.timestampCreated);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import jakarta.persistence.*;
import lombok.Getter;
import lombok.Setter;
import org.springframework.data.util.ProxyUtils;

import java.io.Serial;
import java.io.Serializable;
Expand Down Expand Up @@ -74,7 +75,7 @@ public class DocumentEntity implements Serializable {
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (o == null || !this.getClass().equals(ProxyUtils.getUserClass(o))) return false;
DocumentEntity that = (DocumentEntity) o;
return userId.equals(that.userId) && documentType.equals(that.documentType) && dataType.equals(that.dataType) && documentDataId.equals(that.documentDataId);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import jakarta.persistence.*;
import lombok.Getter;
import lombok.Setter;
import org.springframework.data.util.ProxyUtils;

import java.io.Serial;
import java.io.Serializable;
Expand Down Expand Up @@ -69,7 +70,7 @@ public class PhotoEntity implements Serializable {
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (o == null || !this.getClass().equals(ProxyUtils.getUserClass(o))) return false;
PhotoEntity that = (PhotoEntity) o;
return document.equals(that.document) && photoType.equals(that.photoType) && timestampCreated.equals(that.timestampCreated);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import jakarta.persistence.*;
import lombok.Getter;
import lombok.Setter;
import org.springframework.data.util.ProxyUtils;

import java.time.LocalDateTime;
import java.util.Objects;
Expand Down Expand Up @@ -56,7 +57,8 @@ public class UserClaimsEntity {
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof UserClaimsEntity that)) return false;
if (o == null || !this.getClass().equals(ProxyUtils.getUserClass(o))) return false;
UserClaimsEntity that = (UserClaimsEntity) o;
return userId.equals(that.userId);
}

Expand Down

0 comments on commit 7373d62

Please sign in to comment.