Floris, Most probably, you hit a bug, that was introduced in Ignite 2.0: https://issues.apache.org/jira/browse/IGNITE-5795
Because of this bug @AffinityKeyMapped annotation is ignored in classes, that are used in query entity configuration. As far as I can see, this is exactly your case. It's going to be fixed in Ignite 2.7. There is a workaround for this problem: you can list the problematic classes in BinaryConfiguration#classNames <https://ignite.apache.org/releases/latest/javadoc/org/apache/ignite/configuration/BinaryConfiguration.html#setClassNames-java.util.Collection-> configuration property. Binary configuration should be specified as IgniteConfiguration#binaryConfiguration <https://ignite.apache.org/releases/latest/javadoc/org/apache/ignite/configuration/IgniteConfiguration.html#setBinaryConfiguration-org.apache.ignite.configuration.BinaryConfiguration-> . This configuration should be the same on all nodes. You may also need to configure CacheConfiguration#keyConfiguration <https://ignite.apache.org/releases/latest/javadoc/org/apache/ignite/configuration/CacheConfiguration.html#setKeyConfiguration-org.apache.ignite.cache.CacheKeyConfiguration...-> for your cache. Denis пт, 3 авг. 2018 г. в 16:58, Floris Van Nee <[email protected]>: > Hi all, > > > > I have defined two classes in Java – one for a key and one for a value. > Suppose they look like this: > > > > public static class Key implements Serializable { > > public String a; > > @QuerySqlField > > @AffinityKeyMapped > > public String b; > > } > > public static class Value implements Serializable { > > @QuerySqlField > > public int c; > > } > > > > I then define a distributed cache (in Java) for this key/value pair and > fill it with values (in Java). > > Now, I run the following in SQL: > > SELECT * FROM kv_table; > > I indeed see results of all the stuff that I inserted into the cache. > > > > However, when I try to select a certain value, it returns no results: > > SELECT * FROM kv_table WHERE b = ‘test’; > > I get expected results when filtering on any column that is not defined as > AffinityKeyMapped. > > The only case where I get wrong results is for the AffinityKeyMapped > column - I always get a wrong result (most of the time zero rows, for some > values I do get one row, but I expect to see more rows). Also when I remove > the AffinityKeyMapped annotation and run my test again, everything works as > expected. > > I run just a single server node and execute my query using the SQLLine > tool that Ignite ships with. > > > > Is it possible that there is a bug in the code that handles this affinity > key mapping for SQL queries? Or am I doing something wrong here? > > > > -Floris >
