1

I'm trying to get complex java object from hazelcast using sql approach.

My data object contains embedded object like

Person{
    ...
    HumanName name;
    ...
}
HumanName {
    String firstName;
}

And I'm trying to get this firstName field using sql.

SqlResult result = hz.getSql().execute("SELECT p.id, p.name.firstName FROM Patient as p ");

It says "Column 'name.firstName' not found in table p"

I know it is possible to reach with predicates, like

patientIMap.values( Predicates.equal( "name.firstName", "John" ));

But predicates seems to be not applicable in my case, as I also need to perform Map joins, and it seems to be impossible with predicates.

I also added following mapping:

ClientConfig clientConfig = new ClientConfig();
ClientUserCodeDeploymentConfig clientUserCodeDeploymentConfig = new ClientUserCodeDeploymentConfig();


clientUserCodeDeploymentConfig.addClass("com.example.model.Patient");
clientUserCodeDeploymentConfig.addClass("com.example.model.HumanName");
clientUserCodeDeploymentConfig.setEnabled(true);
clientConfig.setUserCodeDeploymentConfig(clientUserCodeDeploymentConfig);


SerializationConfig serializationConfig = clientConfig.getSerializationConfig().setEnableSharedObject(true);
clientConfig.setSerializationConfig(serializationConfig);
var hz = HazelcastClient.newHazelcastClient(clientConfig);

hz.getSql().execute("CREATE MAPPING \"Patient\" EXTERNAL NAME \"Patient\"\n" +
                "TYPE IMap\n" +
                "OPTIONS (\n" +
                "  'keyFormat' = 'java',\n" +
                "  'keyJavaClass' = 'java.lang.String',\n" +
                "  'valueFormat' = 'java',\n" +
                "  'valueJavaClass' = 'com.example.model.Patient'\n" +
                ")");
  • 1
    Nested field access is not supported in 5.0. We're working right now and hope to release it in Hazelcast 5.1. See https://github.com/hazelcast/hazelcast/pull/19954 – Oliv Dec 10 '21 at 09:35

1 Answers1

0

Nested field access is not supported in 5.0.