P
P
P_Alexander2018-03-28 16:47:46
Java
P_Alexander, 2018-03-28 16:47:46

On what fields to override hashCode() and equals() Hibernate?

I'm interested in the question on which fields these hashCode() and equals() methods are overridden in Hibernate?
I read that, depending on the project, they override different fields in both methods, but usually they override by a unique field that identifies the entity, in this case I have two of them nickname , id , but I still didn’t fully understand the field selection strategy, for example, what if the user want to change nickname!?
They say to use business keys, override them, but don't use autogenerate unique values! And here is an example of how I can redefine here if there are three fields id, vin, lost in the table - and it is unique only by id - how to be here?
Can you enlighten me on this issue, or throw off the scriptures that tell about it??!?! Thank you.
I did this, I generated it using the IDE for all fields except for collections, and what sides can come out?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question