In Ignite I have classes defined as below (with cache configuration for Persons):
public class Person {
@QuerySqlField(index = true)
private long id;
@QuerySqlField
private String name;
@QuerySqlField
private List<Address> addresses;
}
public class Address {
@QuerySqlField
private String street;
@QuerySqlField
private int zip;
}
In sql line when selecting from person (select * from persons), I receive below exception: "Error: Statement is closed. (state=, code=0)"
I found that I can select all fields except of addresses and receive proper result. I thought that it was just unable to print lists. But than it appeared that similar setup had a working query for two other classes (Where the nested class had a separate cache). I tinkered with creating a cache for addresses adding or removing @QuerySqlField in nested classes, but I was not able to reproduce working behavior.
What are the requirements that needs to be made for sqlline queries neatly display array of nested objects?
Technically, nested collections are not supported in Apache Ignite SQL. Instead, you are expected to normalize your SQL schema while using JDBC, sqlline or other tools, i.e. to create a separate
addresses
table and to use joins. And the reason for that is - what would be yourINSERT
statement, and how would you provideaddresses
field?On the other hand, since everything is just a K-V cache underneath, it's possible to utilize Java API for that task. For example, given your models definition but with all methods changed to public:
Output