For the implementation of equals and hashcode in DefaultAssociationKeyMetadata we are considering only the table name and the column names.
This is not enough when an entity has two associations like the following one:
@Entity public class User { ... @OneToMany @MapKeyColumn(name = "priority") Map<Integer, PhoneNumber> phoneNumbersByPriority = new HashMap<>(); @OneToMany @MapStorage(MapStorageType.AS_LIST) @MapKeyColumn(name = "phoneType") Map<String, PhoneNumber> alternativePhoneNumbers = new HashMap<>(); ... }
In this case the association keys will have same table and column names:
DefaultAssociationKeyMetadata [ table=User_PhoneNumber, columnNames=[User_id], collectionRole=phoneNumbersByPriority, ... ] DefaultAssociationKeyMetadata [ table=User_PhoneNumber, columnNames=[User_id], collectionRole=alternativePhoneNumbers, ... ]