Search code examples
gridgain

GridGain join query with both objects returned


Is it possible to return both objects of a join as the result of a GridGain cache query?

We can get either one of the sides of the join or fields from both (and then use these to retrieve each object separately), but looking at the examples and documentation there seems to be no way to get both objects.

Thanks!


Solution

  • @dejan- In GridGain and Apache Ignite, you can use _key and _val functionality with SqlFieldsQuery in order to return an object. For example -

    SqlFieldsQuery sql = new SqlFieldsQuery(
     "select a._key, a._val, b._val from SomeTypeA a, SomeTypeB b " +
       "where a.id = b.otherId");
    
    try (QueryCursor<List<?>> cursor = cache.query(sql) {
      for (List<?> row : cursor)
        System.out.println("Row: " + row);
    }
    

    Note that in this case the object will be returned in a Serialized form.