You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by daniels <ra...@gmail.com> on 2017/11/23 21:13:04 UTC
Cache queries - Failed to run map query remotely
Hi ,
I am using cacheQuery.
My model have one index field
public class Model {
......
.....
@QuerySqlField(index = true)
private Object sortField;
}
this query works properly-
cache.query(new SqlQuery<>(Model.class, "ORDER BY sortField")).getAll();
but when I want to do some filter , for example
cache.query(new SqlQuery<>(Model.class, "sortField= ?").setArgs("10"));
It brings following CacheException- "Failed to run map query remotely"
javax.cache.CacheException: Failed to execute map query on the node:
61a36250-d822-4696-b30c-007943966eed, class
org.apache.ignite.IgniteCheckedException:Failed to execute SQL query.
More details -
<http://apache-ignite-users.70518.x6.nabble.com/file/t524/Screen_Shot_2017-11-24_at_1.png>
--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
Re: Cache queries - Failed to run map query remotely
Posted by daniels <ra...@gmail.com>.
Thank you dear Alexey
--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
Re: Cache queries - Failed to run map query remotely
Posted by Alexey Popov <ta...@gmail.com>.
1. I am not sure that "ORDER BY" works the way you expect ). Very probably it
sorts by some object hash instead casting it to the specific derived type.
2. I don't think you can do it directly. But there are two workaround
options here:
a) keep Object as is, create a new String field just for searching/ordering,
i.e.
@QuerySqlField(index = true)
private String sortFieldKey;
private Object sortField;
b) you can have several caches for each dynamic type you have
Thanks,
Alexey
--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
Re: Cache queries - Failed to run map query remotely
Posted by daniels <ra...@gmail.com>.
Thank you for response,
It worked for me.
But the type of my fields is defined dhnamically. Isn't there an option to
keep the object type?
And what you think, how works "ORDER BY" ,when sortField type is Object?
--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
Re: Cache queries - Failed to run map query remotely
Posted by Alexey Popov <ta...@gmail.com>.
Hi daniels,
Just change the type of sortField from Object to more specific type, for
instance, to "Integer" one.
@QuerySqlField(index = true)
private Integer sortField;
I am not sure if SQL engine should be able to somehow cast Object to compare
with "1".
Thank you,
Alexey
--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/