Let's imagine I have a column which holds JSON/JSONB representation of internal information for triggering or caching policy handling, whatever.
Let's imagine also a lot of tables have such column. From table to table 80% of information has the same structure. For example:
{
"date_created":"2017-12-28 16:15:48.381194+06",
"date_updated":"2017-12-08 17:42:33.133355+06",
"is_active":true,
"is_withdrawn":false,
"premission_type":"SPECIAL",
"cache_key":"some_unique_cache_key",
"cache_expiration":"3600"
}
Of course JSON type if not supported by Olingo according to https://olingo.apache.org/javadoc/odata4/org/apache/olingo/commons/api/edm/EdmPrimitiveType.html
and I have to treat it as STRING. But Apache can't process big structures and produces an error in https://github.com/apache/olingo-odata4/blob/d9aff6300f61750d7f1a20d8ae58c322d8cde4e3/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/xml/ODataXmlSerializer.java#L857
Will report issue on Apache later.
So finally, querying entity getting this
{
"@odata.context":"$metadata#Table_Companies",
"value":[
{
"Data":"{ \"date_created\":\"2017-12-28 16:15:48.381194+06\", \"date_updated\":\"2017-12-08 17:42:33.133355+06\", \"is_active\":true, \"is_withdrawn\":false, \"premission_type\":\"SPECIAL\", \"cache_key\":\"some_unique_cache_key\", \"cache_expiration\":\"3600\"} ",
"Identity":"1234567890123",
"Name":"Company #1",
"Id":4,
"LegalFormId":1
},
{
"Data":"{ \"date_created\":\"2017-12-28 16:15:48.381194+06\", \"date_updated\":\"2017-12-08 17:42:33.133355+06\", \"is_active\":true, \"is_withdrawn\":false, \"premission_type\":\"SPECIAL\", \"cache_key\":\"some_unique_cache_key\", \"cache_expiration\":\"3600\", \"another_key\": true}",
"Identity":"120640010032",
"Name":"Company #2",
"Id":2,
"LegalFormId":3
}
]
}
Is there any idea how to get structure like this
{
"@odata.context":"$metadata#Table_Companies",
"value":[
{
"Data":{
"date_created":"2017-12-28 16:15:48.381194+06",
"date_updated":"2017-12-08 17:42:33.133355+06",
"is_active":true,
"is_withdrawn":false,
"premission_type":"SPECIAL",
"cache_key":"some_unique_cache_key",
"cache_expiration":"3600"
},
"Identity":"1234567890123",
"Name":"Company #1",
"Id":4,
"LegalFormId":1
},
{
"Data":{
"date_created":"2017-12-28 16:15:48.381194+06",
"date_updated":"2017-12-08 17:42:33.133355+06",
"is_active":false,
"is_withdrawn":true,
"premission_type":"INTERNAL",
"cache_key":"some_unique_cache_key",
"cache_expiration":"300",
"SPECIAL_KEY_ONLY_FOR_THIS_ROW":true
},
"Identity":"120640010032",
"Name":"Company #2",
"Id":2,
"LegalFormId":3
}
]
}
I think I can use ComplexType but still not sure how to implement it and handle non standart keys like SPECIAL_KEY_ONLY_FOR_THIS_ROW
Any ideas?