If you enable SQL on your table, then you can run a query that filters on a 
subset of the properties. You can also add an index to make the lookup more 
quickly.

> On 17 Jun 2022, at 16:55, Saurabh Satardekar <satardekarsaur...@gmail.com> 
> wrote:
> 
> Respected Sir/Madam,
> We have following use case where we have Book class as follows :
> 
> public class Book {
> 
> private int price;
> private String bookName;
> private String authorName;
> 
> public Book( String bookName, String authorName, int price ) {
> this.bookName = bookName;
> this.authorName = authorName;
> this.price = price;
> }
> 
> @Override
> public boolean equals(Object o) {
> if( this == o ) return true;
> if( o == null || getClass() != o.getClass() ) return false;
> Book that = (Book) o;
> return bookName.equals(that.bookName) && authorName.equals(that.authorName);
> }
> 
> @Override
> public int hashCode() {
> return Objects.hash(bookName,authorName);
> }
> }
> 
> For the above class we need to compare books by using book name and its 
> author name only. We don't want to include price while comparing books but we 
> can't even store that information anywhere else.
> So if I have two objects as follows :
> 
> Book book_1 = new Book("Book_1","ABC",100);
> Book book_2 = new Book("Book_1","ABC",200);
> 
> For above objects, if I use book_1 object as my cache key and put some value 
> against it into cache, I am not able to retrieve that value using my another 
> object book_2 as ignite is not honoring equals method provided on Book class.
> 
> We have tried implementing Externalizable interface and also by providing 
> custom implementation of BinaryIdentityResolver interface. Still we are not 
> getting desired output.
> 
> Note : This is a sample class which we have used to describe a problem, in 
> reality we are using other classes and we have a valid use case where we 
> don't want to use all attributes of the class while comparing them for 
> equality ( in equals and hashCode method ).
> 
> Thank you,
> Saurabh Satardekar.

Reply via email to