Created
June 18, 2010 15:28
Hibernate entity equals
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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