I have two objects
One by lazy loaded
product:5757b95d1d8eecdd01e59b29$LazyLoadingProxy
The other eager loaded
com.entity.Product@5e6c4568
I know both objects are the same since they have the same unique id (id=5757b95d1d8eecdd01e59b29
).
I have in my Product
class following methods:
@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;
}
But now when I do the following operation I get no match. Any clues ?
temp.contains(product) == false
temp
contains the lazy loaded items and product
contains normal items.