You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

29 lines
685 B

package app.data.entity;
import lombok.Getter;
import lombok.Setter;
import javax.persistence.*;
@Getter
@Setter
@MappedSuperclass
public abstract class AbstractEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id", nullable = false)
private Integer id;
@Override
public int hashCode() {
return id != null ? id.hashCode() : super.hashCode();
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof AbstractEntity)) return false; // null or other class
AbstractEntity other = (AbstractEntity) obj;
return id != null ? id.equals(other.id) : super.equals(other);
}
}