mirror of https://github.com/halo-dev/halo
Customize PostCategory#equals and PostTag#hashCode
parent
c5e675ce66
commit
3d80e34215
|
@ -9,6 +9,7 @@ import org.hibernate.annotations.Where;
|
|||
|
||||
import javax.persistence.*;
|
||||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Post category entity.
|
||||
|
@ -21,7 +22,6 @@ import java.util.Date;
|
|||
@Where(clause = "deleted = false")
|
||||
@Data
|
||||
@ToString
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class PostCategory extends BaseEntity {
|
||||
|
||||
@Id
|
||||
|
@ -46,4 +46,19 @@ public class PostCategory extends BaseEntity {
|
|||
super.prePersist();
|
||||
id = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
if (!super.equals(o)) return false;
|
||||
PostCategory that = (PostCategory) o;
|
||||
return categoryId.equals(that.categoryId) &&
|
||||
postId.equals(that.postId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(super.hashCode(), categoryId, postId);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue