I have an entity, let's say an item which uses a Lombok annotation
@EqualsAndHashCode(callSuper = true) which autogenerates equals() and hashCode() methods.
The entities are put inside a HashSet collection.
The problem is that when I am getting the collection from the DB (Spring JPARepository with Hibernate) PersistentSet proxy with my items in HashSet and when I am using the Lombok @EqualsAndHashCode the method persistentSet.contains(object) returns false. When my hashCode() returns 1 or other value but without the Lombok auto-generated methods, it works fine -> persistentSet.contains(object) returns true. What else the Lombok autogenerated hashCode() also seems fine because it returns the constant value for the given object within session. So I am lost.
Maybe someone has an idea what may we wrong here !?
Versions:
Hibernate: 5.3.9.Final
Lombok: 1.18.10
database: MySQL
Spring: 5.1.9.RELEASE