我有两个对象
一个通过延迟加载
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
包含普通项目。