I am wondering if Apache Ignite Spring Data implementation supports the concept of projections to facilitate retrieving only a subset of the fields/attributes of cache entities instead of fetching the entire entity which may have lots of columns.
In the docs i see an example where only one attribute of the cache entity is fetched as reproduced below.
/**
* Getting ids of all the Person satisfying the custom query from {@link Query} annotation.
*
* @param orgId Query parameter.
* @param pageable Pageable interface.
* @return A list of Persons' ids.
*/
@Query("SELECT id FROM Person WHERE orgId > ?")
public List<Long> selectId(long orgId, Pageable pageable);
Taking the above example, how does one do this if one needs BOTH the "id" & "firstName", "lastName" of "Person" entity instead of just the "id" as above?
Thanks
UPDATE (Post the answer from @alamar): Thanks @alamar! I am also reproducing the method declaration & its usage code from Spring Data Test code so its easy for others to follow the answer.
/** */
@Query("SELECT _key, secondName FROM Person WHERE firstName REGEXP ?")
public List<List> selectSeveralField(String val, Pageable pageable);
/** */
public void testSelectSeveralFields() {
List<List> lists = repo.selectSeveralField("^[a-z]+$", new PageRequest(2, 6));
assertEquals(6, lists.size());
for (List list : lists) {
assertEquals(2, list.size());
assertTrue(list.get(0) instanceof Integer);
}
}
However having Spring Data Projections type mechanism which does away with troublesome casting in user code would have been nicer.
From Spring Data test:
@Query("SELECT _key, secondName FROM Person WHERE firstName REGEXP ?")
public List<List> selectSeveralField(String val, Pageable pageable);
E.g. yes, you can list multiple fields and get list of lists (tuples) of those fields.