You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by the_palakkaran <ji...@suntecsbs.com> on 2018/06/06 07:03:52 UTC
How Ignite performs cache.get() operation when hashCode is
overridden ?
<http://apache-ignite-users.70518.x6.nabble.com/file/t1795/Capture.jpg>
See the image attached. I have put keys into the cache using the equals
method as follows:
@Override
public boolean equals(Object obj) {
HierarchyMasterKey hierarchyMasterKey = (HierarchyMasterKey) obj;
return equalTo(this.hmCustNo, hierarchyMasterKey.hmCustNo) &&
equalTo(this.hmFromDate, hierarchyMasterKey.hmFromDate) &&
equalTo(this.hmParentCustNo,
hierarchyMasterKey.hmParentCustNo) &&
equalTo(this.hmActNo, hierarchyMasterKey.hmActNo);
}
(equalTo method is basically null safe equals check.)
and hashCode is computed as below:
@Override
public int hashCode() {
return Objects.hash(hmCustNo,hmActNo);
}
When I try to get from it,
the equals method won't get executed. Why is this so? How does ignite get
the key without executing equals?
[I have a cache that has a HierarchyMasterKey and a list of HierarchyMaster
as values]
--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
Re: How Ignite performs cache.get() operation when hashCode is
overridden ?
Posted by Andrey Mashenkov <an...@gmail.com>.
Duplicate.
Answeder on SO [1]
[1]
https://stackoverflow.com/questions/50714462/how-ignite-performs-cache-get-operation-when-hashcode-is-overridden
On Wed, Jun 6, 2018 at 10:03 AM, the_palakkaran <ji...@suntecsbs.com>
wrote:
> <http://apache-ignite-users.70518.x6.nabble.com/file/t1795/Capture.jpg>
>
>
> See the image attached. I have put keys into the cache using the equals
> method as follows:
>
>
> @Override
> public boolean equals(Object obj) {
> HierarchyMasterKey hierarchyMasterKey = (HierarchyMasterKey) obj;
> return equalTo(this.hmCustNo, hierarchyMasterKey.hmCustNo) &&
> equalTo(this.hmFromDate, hierarchyMasterKey.hmFromDate) &&
> equalTo(this.hmParentCustNo,
> hierarchyMasterKey.hmParentCustNo) &&
> equalTo(this.hmActNo, hierarchyMasterKey.hmActNo);
> }
>
> (equalTo method is basically null safe equals check.)
>
> and hashCode is computed as below:
>
> @Override
> public int hashCode() {
> return Objects.hash(hmCustNo,hmActNo);
> }
>
>
> When I try to get from it,
> the equals method won't get executed. Why is this so? How does ignite get
> the key without executing equals?
>
> [I have a cache that has a HierarchyMasterKey and a list of HierarchyMaster
> as values]
>
>
>
>
>
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>
--
Best regards,
Andrey V. Mashenkov