私は2つのオブジェクトを持っています
遅延読み込みによる 1 つ
product:5757b95d1d8eecdd01e59b29$LazyLoadingProxy
もう一方の熱心なロード
com.entity.Product@5e6c4568
同じ一意の ID ( ) を持っているため、両方のオブジェクトが同じであることがわかりますid=5757b95d1d8eecdd01e59b29
。
Product
クラスに次のメソッドがあります。
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = (prime * result) + ((id == null) ? 0 : id.hashCode());
return result;
}
@Override
public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final Item other = (Item) obj;
if (id == null) {
if (other.id != null) {
return false;
}
} else if (!id.equals(other.id)) {
return false;
}
return true;
}
しかし、次の操作を行うと、一致しません。手がかりはありますか?
temp.contains(product) == false
temp
遅延ロードされたアイテムをproduct
含み、通常のアイテムを含みます。