Skip to content

Can't ignore significant @Id field #785

Answered by jqno
bjansen asked this question in Q&A
Discussion options

You must be logged in to vote

EqualsVerifier has recently become a bit more rigorous when it comes to JPA entities. There's a debate on whether it's better to give entities a business key (aka natural key), or a surrogate key. A business key is when all the semantically meaningful fields are part of the object's identity and assumes that the key is just there for technical reasons and doesn't actually mean anything for the user. A surrogate key is when the object's identity relies exclusively on the key, and the actual content of the fields doesn't matter.

EqualsVerifier assumes a business key by default, which means that you can't use id in equals. If you want EqualsVerifier to assume a surrogate key, you can suppress

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@bjansen
Comment options

Answer selected by jqno
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants