[
https://issues.apache.org/jira/browse/OLINGO-1129?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16105064#comment-16105064
]
Hui Wang commented on OLINGO-1129:
----------------------------------
Hi Ramya,
This is our current situation: All of the required data has been already
fetched from database based on the uri, and has been properly set into the
EntityCollection that is going to be serialized ( including all of the inline
entities ). When doing $expand on a navigation property, the inline entities
would be completely fetched from the database including all of their
properties. If type casts is included in the expand, our data generator
processor will fetch the properties that belong to the derived type as well. I
think everything has been well prepared before the Serializer. But the
Serializer didn't serialize the additional properties that were already
included in the EntityCollection into JSON.
I think in ODataJsonSerializer.writeExpandedNavigationProperty(), these lines
are responsible for writing the inline entity into the json:
{code:java}
} else {
writeEntity(metadata, property.getType(),
navigationLink.getInlineEntity(), null,
innerExpand, toDepth, innerSelect, writeOnlyRef, ancestors, json);
}
{code}
It seems that property.getType() provides the EdmEntityType that indicates what
entity type should be written, and navigationLink.getInlineEntity() gets the
inline entity from the prepared object (here we have provided all of the
properties). I think the problem is that the EdmEntityType retrieve by
property.getType() is only a base type because that is how the navigation
property is defined in the metadata. And it didn't inform writeEntity() about
the derived type, therefore the method didn't know it should write the extra
properties for the derived type.
Hui
> ODataJsonSerializer Does Not Support Derived Type in $expand Option
> -------------------------------------------------------------------
>
> Key: OLINGO-1129
> URL: https://issues.apache.org/jira/browse/OLINGO-1129
> Project: Olingo
> Issue Type: New Feature
> Components: odata4-server
> Affects Versions: (Java) V4 4.3.0
> Reporter: Hui Wang
> Priority: Minor
>
> Currently we need to use type casting to a derived type in $expand. Here is
> the corresponding part in the OData Protocol.
> http://docs.oasis-open.org/odata/odata/v4.0/errata03/os/complete/part2-url-conventions/odata-v4.0-errata03-os-part2-url-conventions-complete.html#_Toc453752352
> To reproduce:
> Here is an example URL provided in the documentation that could be used for
> reproducing the defect:
> http://host/service/Orders?$expand=Customer/Model.VipCustomer
> In the current 4.3 version, ODataJsonSerializer only deals with expand on
> Customer but ignores the type filter Model.VipCustomer. It means, the
> response would only show the content of super type Customer. Any custom
> properties in derived type VipCustomer wouldn't be returned.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)