Skip to content

Instantly share code, notes, and snippets.

@pavlukhin
Created October 17, 2019 12:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pavlukhin/362c0e40d4a010a8f7c0795368e53efb to your computer and use it in GitHub Desktop.
Save pavlukhin/362c0e40d4a010a8f7c0795368e53efb to your computer and use it in GitHub Desktop.
Nested POJO and QueryEntity bug
class User {
String userName;
Address address;
public User(String userName, Address address) {
this.userName = userName;
this.address = address;
}
}
class Address {
String streetName;
String zipcode;
public Address(String streetName, String zipcode) {
this.streetName = streetName;
this.zipcode = zipcode;
}
}
@Test
public void testSqlPojoWithoutAnnotations() throws Exception {
IgniteEx grid = startGrid(0);
LinkedHashMap<String, String> fields = new LinkedHashMap<>();
fields.put("userName", "String");
fields.put("address.zipcode", "String");
IgniteCache<Object, Object> cache = grid.createCache(new CacheConfiguration<>(DEFAULT_CACHE_NAME)
.setQueryEntities(Collections.singleton(new QueryEntity(Integer.class, User.class)
.setFields(fields))));
cache.put(1, new User("ivan", new Address("a", "123")));
System.err.println(cache.query(new SqlFieldsQuery("select * from User")).getAll());
System.err.println(cache.query(new SqlFieldsQuery("select zipcode from User")).getAll());
cache.query(new SqlFieldsQuery("create index on User(zipcode)"));
System.err.println(cache.query(new SqlFieldsQuery("select zipcode from User")).getAll());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment