0

In our product we are using Ignite ClientCache to cache objects. We are using a class object as key to store in cache. Now when I create another drive class object and store it in ClientCache cache. Here I am adding drive class object in Baseclass cache, and after I added a child class object, I have updated some of its member fields, before removable. Now when I call ClientCache.remove() on such drive class object it fails to find such key. So my question is how can I provide custom comparator, I have already tried java equals() and hashcode() function overriding, but it does not work.

Bishnu
  • 73
  • 7
  • I'm not entirely clear what you're doing here. Can you share some code samples? What I would say is that Ignite isn't an object database (though it looks like one from some angles). – Stephen Darlington Nov 25 '21 at 11:51
  • Sorry for the confusion. But I my case we are using a BaseClass object which extends Externalizable interface as a key in – Bishnu Nov 26 '21 at 03:10
  • Sorry for the confusion. In my case we are using a BaseClass object which implements Externalizable interface and use It as a key in Ignite ClientCache. Now I have created another DriveClass which is extending the BaseClass. Now when I create a key object for my DriveClass and add() it into ClientCache, at the time of removable remove() is not able to find that key and returning false. I have already overridden equals() and hashCode() in my DriveClass and made sure that hash value which I get same as hash value during remove(), but remove() is still failing. What can I do in this case ? – Bishnu Nov 26 '21 at 03:37

1 Answers1

1

Ignite considers two objects equal when all of the following is true:

  • Type ID is the same (same class).
  • Serialized representation (byte[]) is the same.

Ignite does not use standard equals() and hashCode() for comparisons, because the DB engine operates on serialized data. There is no way to override this behavior.

Pavel Tupitsyn
  • 8,393
  • 3
  • 22
  • 44