You must correctly implement equals method for your classes, looking also at inner objects, using something like this
@Override
public boolean equals(Object o) {
if (o == this) return true;
if (!(o instanceof Book)) return false;
Book other = (Book) o;
if (!other.canEqual((Object)this)) return false;
if (!super.equals(o)) return false;
if (!this.other.author.equals(this.author)) return false;
return true;
}
If don't want particular behaviour you can use Lombok with its @EqualsAndHashCode annotation
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…