Copying my reply from StackOveflow [1] here.
Use `_key` and `_val` keywords to retrieve the entire key and/or value
objects.
IgniteCache<Long, Person> cache = ignite.cache("Person");
SqlFieldsQuery sql = new SqlFieldsQuery(
"select _val from Person where age > ?", 28);
try (QueryCursor<List<?>> cursor = cache.query(sql)) {
for (List<?> row : cursor) {
Person p = (Person) row.get(0);
System.out.println(p);
}
}
[1]
https://stackoverflow.com/questions/66248464/how-to-get-ignite-cache-sql-query-to-return-value-object
On Wed, Feb 17, 2021 at 8:59 PM PunxsutawneyPhil3 <[email protected]>
wrote:
> I have a Postgres database configured as my persistence layer and would
> like
> to execute SQL queries against the Postgres tables cached in Ignite.
>
> Ideally I'd like to execute a query on these caches and be returned the
> Value objects t represented by these tables.
>
> SqlQuery gives me the functionality that I am looking for but is
> deprecated.
>
> SqlFieldsQuery would work, but I would prefer not to have to deal with the
> row data a List<?>. Is there a way to get SqlFieldsQuery to return the
> value as an object and now as a list of its Fields?
>
> It looks like Continuous query is a possible alternative but I am not
> interested in listening to cache updates.
>
> Thanks.
>
>
>
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>