Reputation: 157
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" +
")");
Upvotes: 1
Views: 339