What is the correct way of overriding hashCode () and equals () methods of persistent entity?

后端 未结 7 2087
青春惊慌失措
青春惊慌失措 2020-12-14 10:28

I have a simple class Role:

@Entity
@Table (name = \"ROLE\")
public class Role implements Serializable {

    @Id
    @GeneratedValue
    private Integer id;         


        
7条回答
  •  余生分开走
    2020-12-14 10:37

    Knowing when overriding the hashCode and equals is not an easy task, there is another discussion where you have example and documentation link here What issues should be considered when overriding equals and hashCode in Java?

提交回复
热议问题