How to use @EqualsAndHashCode
With Include
, Lombok library for Java.
@EqualsAndHashCode.Include( )
How to make Equal
You should use it on the field, it's not something to be used on the class itself. You can check this by checking the definition of the annotation which defines the following targets (field and method, not a class)
@Target({ElementType.FIELD, ElementType.METHOD})
Here is an example of how to use it
@EqualsAndHashCode(onlyExplicitlyIncluded = true)
@Table(name = "USER")
public class User
{
@Id
@EqualsAndHashCode.Include()
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "IDENTITY_USER")
private Long identity;
}