Skip to content

Instantly share code, notes, and snippets.

@dredom
Created June 18, 2010 15:28
Hibernate entity equals
@Entity
@Table(name = "MY_TABLE")
public class MyTable extends AbstractEntity {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private String value1;
private String value2;
...
public boolean equals(Object obj) {
if (obj == null || !(obj.getClass().equals(this.getClass()))) {
return false;
}
return getId().equals(((GenericEntity ) obj).getId());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment