[
https://issues.apache.org/jira/browse/OLINGO-508?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14242654#comment-14242654
]
Michael Bolz commented on OLINGO-508:
-------------------------------------
Hi [~Yaofeng],
I take a quick look into this issue and IMHO the problem is (as you mentioned)
that the auto genereated {{toRole}} and {{fromRole}} has the same name.
This is not allowed and can't be handled by the default processor.
A simple fix would be to add a {{f}} and {{t}} to differentiate between the two
roles in such a case.
But before I commit it I have to do some additional checks.
Kind regards, Michael
{code}
public String extractFromRoleName(final EdmNavigationProperty enp, final
Field field) {
return "f" + getCanonicalRole(field.getDeclaringClass());
}
public String extractToRoleName(final EdmNavigationProperty enp, final Field
field) {
String role = enp.toRole();
if (role.isEmpty()) {
role = getCanonicalRole(
field.getType().isArray() ||
Collection.class.isAssignableFrom(field.getType()) ?
(Class<?>) ((ParameterizedType)
field.getGenericType()).getActualTypeArguments()[0] : field.getType());
}
return "t" + role;
}
{code}
> One-to-Many self-link causing NotImplementedException
> -----------------------------------------------------
>
> Key: OLINGO-508
> URL: https://issues.apache.org/jira/browse/OLINGO-508
> Project: Olingo
> Issue Type: Bug
> Components: odata2-annotation, odata2-core
> Affects Versions: V2 2.0.1
> Reporter: Yaofeng Xu
> Assignee: Michael Bolz
>
> An exception will be thrown when expanding an inline entity which is a
> one-to-many relationship to the entity itself.
> My entity model:
> @EdmEntityType
> @EdmEntitySet(name="Manufacturers")
> public class Manufacturer {
> @EdmKey
> @EdmProperty
> private String id;
> @EdmProperty
> private String name;
> @EdmProperty
> private Calendar founded;
> @EdmNavigationProperty
> private List<Car> cars;
> @EdmNavigationProperty
> private List<Manufacturer> subManufacturers;
>
> }
> Request:
> http://localhost:8080/PqmODataExample/PqmODataExample.svc/Manufacturers('1')?$expand=SubManufacturers
> Response:
> {"error":{"code":null,"message":{"lang":"en","value":"Not implemented"}}}
> A workaround is to add toRole to the navigation property annotation as
> "@EdmNavigationProperty(toRole="r-manufacturers")".
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)