Pavel, Ilya, I think we should implement such a check on insert. It can be optional (for example enabled by property in SqlConfiguration). The sooner we found the problem - the better.
вт, 26 мая 2020 г. в 17:56, Ilya Kasnacheev <ilya.kasnach...@gmail.com>: > Hello! > > I'm not aware about any mechanism like this one built in Apache Ignite. > > I advise you to wrap Ignite's APIs into ones of your own and avoid using > raw Ignite API. This way you will make sure to do these checks on your own. > > Regards, > -- > Ilya Kasnacheev > > > пн, 25 мая 2020 г. в 15:22, Pavel Pereslegin <xxt...@gmail.com>: > > > Hello Igniters. > > > > If type of binary field does not match query entity field type we > > still able to insert such entry into cache, but can't query it. > > In the following example we have query entity with the UUID field > > "name", but we insert String field "name" using binary object. > > > > IgniteCache<Object, Object> cache = grid(0).createCache( > > new CacheConfiguration<>("testCache").setQueryEntities( > > Collections.singletonList( > > new QueryEntity() > > .setKeyFieldName("id") > > .setValueType("Person") > > .setFields(new LinkedHashMap<>( > > F.asMap("id", "java.lang.Integer", > > "name", "java.util.UUID")))))); > > > > BinaryObject obj = grid(0).binary().builder("Person") > > .setField("id", 1) > > .setField("name", UUID.randomUUID().toString()) > > .build(); > > > > cache.put(1, obj); > > assertEquals(obj, cache.withKeepBinary().get(1)); > > > > String sql = "select id, name from Person where id=1"; > > > > grid(0).context().query() > > .querySqlFields(new > > SqlFieldsQuery(sql).setSchema("testCache"), true) > > .getAll(); // java.lang.ClassCastException: > > java.lang.String cannot be cast to java.util.UUID > > > > The object was successfully inserted, but the "name"-field cannot be > > read using sql. > > > > Should it be better to prevent insertion of cache entry if the binary > > field type and the type of the query entity field do not match? > > >