I have following "Person" data model:
public class Address implements Binarylizable {
@QuerySqlField
private String street;
@QuerySqlField
private String city;
@QuerySqlField
private String state;
@QuerySqlField
private int zip;
@QuerySqlField
private String country;
...
}
public class Person implements Binarylizable {
@QuerySqlField(index = true)
private String name;
@QuerySqlField
private Date dateOfBirth;
@QuerySqlField
private String email;
@QuerySqlField
private String[] telephoneNumber;
@QuerySqlField
private *Address homeAddress*;
@QuerySqlField
private *Address workAddress*;
...
}
public class PersonKey implements Binarylizable {
@GridToStringInclude
@QuerySqlField(index = true)
private String personKey;
@AffinityKeyMapped
@QuerySqlField(index = true)
private String orgKey;
...
}
Now, when I create a cache for it and start working with it, I get the
following data model for SQL:
CREATE MEMORY TABLE "example.com:Person".PERSON(
_KEY OTHER INVISIBLE NOT NULL,
_VAL OTHER INVISIBLE ,
_VER OTHER INVISIBLE ,
PERSONKEY VARCHAR,
ORGKEY VARCHAR,
NAME VARCHAR,
DATEOFBIRTH TIMESTAMP,
EMAIL VARCHAR,
TELEPHONENUMBER ARRAY,
*HOMEADDRESS* OTHER,
STREET VARCHAR,
CITY VARCHAR,
STATE VARCHAR,
ZIP INT,
COUNTRY VARCHAR,
*WORKADDRESS* OTHER
)
ENGINE "org.apache.ignite.internal.processors.query.h2.H2TableEngine"
It's a very basic data model, but I have problems working with it. Hence, I
would like to ask a few questions:
1. I'm able to query a Person based on it's homeAddress zip (with "SELECT *
FROM Person WHERE zip = 123"), but I'm unable to do so based on workAddress
zip. How can that be achieved?
2. How I can control how Ignite flattens the nested objects? Can I control
that?
3. Can I avoid flattening and use nested names in my SQL query "SELECT *
FROM Person WHERE workAddress.zip = 123"? I think I've seen some examples of
that but I could not figure out how to make it work.
4. The table structure indicates that both the "HOMEADDRESS OTHER" and all
of its fields present in the table. Does it mean that Ignite will store and
manage homeAddress data twice?
I'm running Ignite 2.6 and simple example-ignite.xml to run the nodes.
--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/