46 lines
915 B
Java
46 lines
915 B
Java
package com.cubetiqs.fusion.data;
|
|
|
|
import javax.persistence.GeneratedValue;
|
|
import javax.persistence.Id;
|
|
import javax.persistence.MappedSuperclass;
|
|
|
|
import com.vaadin.fusion.Nonnull;
|
|
|
|
@MappedSuperclass
|
|
public abstract class AbstractEntity {
|
|
|
|
@Id
|
|
@GeneratedValue
|
|
@Nonnull
|
|
private Integer id;
|
|
|
|
public Integer getId() {
|
|
return id;
|
|
}
|
|
|
|
public void setId(Integer id) {
|
|
this.id = id;
|
|
}
|
|
|
|
@Override
|
|
public int hashCode() {
|
|
if (id != null) {
|
|
return id.hashCode();
|
|
}
|
|
return super.hashCode();
|
|
}
|
|
|
|
@Override
|
|
public boolean equals(Object obj) {
|
|
if (!(obj instanceof AbstractEntity)) {
|
|
return false; // null or other class
|
|
}
|
|
AbstractEntity other = (AbstractEntity) obj;
|
|
|
|
if (id != null) {
|
|
return id.equals(other.id);
|
|
}
|
|
return super.equals(other);
|
|
}
|
|
}
|