org.example.jpadomain.AbstractEntity Maven / Gradle / Ivy
The newest version!
package org.example.jpadomain;
import javax.persistence.*;
import java.io.Serializable;
import java.util.Objects;
@MappedSuperclass
public abstract class AbstractEntity implements Serializable, Cloneable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@SequenceGenerator(name = "test")
public Long id;
public Long getId() {
return id;
}
protected void setId(Long id) {
this.id = id;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (this.id == null) {
return false;
}
if (obj instanceof AbstractEntity && obj.getClass().equals(getClass())) {
return this.id.equals(((AbstractEntity) obj).id);
}
return false;
}
@Override
public int hashCode() {
int hash = 5;
hash = 43 * hash + Objects.hashCode(this.id);
return hash;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy