0

Sample Class

public class PersonImpl{
   private String firstName;
   private String lastName
   private HashMap<Integer,String> attributes;
}

While using sqlFields query, it works with firstName and lastName, but all attributes cannot be fetched with sqlFieldsQuery

For example, select firstName from PersonImpl gives the result, but select attributes from PersonImpl does not fetch results and gives error Failed to deserialize Object

Is it not possible to fetch collections with ApacheIgnite.

Olaf Kock
  • 46,930
  • 8
  • 59
  • 90
Krishna
  • 1
  • 1

1 Answers1

0

Can you show some more of your code? This should work. I tried this and it worked for example:

        var cacheConfiguration = new CacheConfiguration<Long,PersonImpl>()
                .setName("PERSON")
                .setIndexedTypes(Long.class, PersonImpl.class);
        var cache = ignite.<Long,PersonImpl>getOrCreateCache(cacheConfiguration);

        var attr = new HashMap<Integer,String>();
        attr.put(1,"London");
        attr.put(2,"United Kingdom");
        cache.put(1L, new PersonImpl("John", "Smith", attr));

        try (var cursor = cache.query(new SqlFieldsQuery("select attributes from PersonImpl where _key = ?").setArgs(1L))) {
            for (var e : cursor) {
                System.out.println(e);
            }
        }
Stephen Darlington
  • 51,577
  • 12
  • 107
  • 152