Hibernate documentation suggests to have equals and hashCode methods implemented if you have composite key. See usage of groovy's @EqualsAndHashCode for that purpose in other data types.