Reputation: 267
Suppose I have a class like the below, I want to put objects like this into the cache and query them using SQL. Is the usage of the @QuerySqlField annotation on methods like on the getTotal() method below supported? When I query my cache with SQL I keep getting null for the total field, it is also null when I check in the h2 database, so I am not sure whether this use case is not supported or whether I am doing it wrong. The javadocs say that the annotation is ok for fields and methods. Can anyone help please?
public class Stats {
@QuerySqlField private double cats;
@QuerySqlField private double dogs;
...
@QuerySqlField(name="total")
public double getTotal() { return cats + dogs; }
}
Upvotes: 1
Views: 278
Reputation: 8390
By default Ignite uses binary format [1] to store the data and doesn't deserialize objects on server side, so method invocations are not available. You can make it work by switching to OptimizedMarshaller
, but this is not a recommended approach as it's a legacy serialization format.
Note that in Ignite 2.0 OptimizedMarshaller
will be deprecated and @QuerySqlField
annotation will be restricted to fields.
[1] https://apacheignite.readme.io/docs/binary-marshaller
Upvotes: 3