Created
October 17, 2019 12:08
-
-
Save pavlukhin/362c0e40d4a010a8f7c0795368e53efb to your computer and use it in GitHub Desktop.
Nested POJO and QueryEntity bug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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