[ https://issues.apache.org/jira/browse/OLINGO-204?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13933042#comment-13933042 ]
Ralf Handl commented on OLINGO-204: ----------------------------------- Hi Michele, This restriction is also present in OData 4.0. The solution is to include the foreign-key properties in the dependent entity type in addition to the navigation property and declare their dependency via referential constraints in the navigation property. In example 10 in http://docs.oasis-open.org/odata/odata/v4.0/os/part3-csdl/odata-v4.0-os-part3-csdl.html#_Toc372793925 a product must be related to a product category, and the category key property is part of the product entity. This would allow to make the CategoryID part of the product key (which is not shown in the example). Hope this helps! --Ralf > EntityType with NavigationProperty Key > -------------------------------------- > > Key: OLINGO-204 > URL: https://issues.apache.org/jira/browse/OLINGO-204 > Project: Olingo > Issue Type: Question > Components: odata2-core > Affects Versions: V2 1.1.0 > Reporter: M Carissimi > Assignee: Christian Amend > Fix For: V2 1.2.0 > > > Hello, > I have some EntityTypes which define as Key one of the NavigationProperties. > For example EntityType AA_SEL_TEST_2 specifies as part of the Key the > property OBJECT_REF which is a NavigationProperty for AA_SEL_TEST_1 > {code} > <EntityType Name="AA_SEL_TEST_2"> > <Key> > <PropertyRef Name="NAME"/> > <PropertyRef Name="OBJECT_REF"/> > </Key> > <Property Name="GUID" Type="Edm.String" Nullable="false"/> > <Property Name="NAME" Type="Edm.String" Nullable="false"/> > <Property Name="FLOW" Type="esys_producer.NumberAndUnits" Nullable="false"/> > <NavigationProperty Name="OBJECT_REF" > Relationship="esys_producer.AA_SEL_TEST_2_to_AA_SEL_TEST_1" > FromRole="r_AA_SEL_TEST_2" ToRole="r_AA_SEL_TEST_1"/> > </EntityType> > <EntityType Name="AA_SEL_TEST_1"> > <Key> > <PropertyRef Name="NAME"/> > <PropertyRef Name="IS_ACTIVE"/> > <PropertyRef Name="PRODUCTION_DATE"/> > </Key> > <Property Name="GUID" Type="Edm.String" Nullable="false"/> > <Property Name="NAME" Type="Edm.String" Nullable="false"/> > <Property Name="IS_ACTIVE" Type="Edm.Boolean" Nullable="false"/> > <Property Name="PRODUCTION_DATE" Type="Edm.DateTime" Nullable="false"/> > </EntityType> > {code} > When I request the feed containing all entries for EntityType AA_SEL_TEST_1 I > get all the data, but when I request the feed for entries of type > AA_SEL_TEST_2 I get an exception > {code} > SEVERE: java.lang.NullPointerException > at > org.apache.olingo.odata2.core.ep.producer.AtomEntryEntityProducer.createEntryKey(AtomEntryEntityProducer.java:538) > at > org.apache.olingo.odata2.core.ep.producer.AtomEntryEntityProducer.createSelfLink(AtomEntryEntityProducer.java:524) > at > org.apache.olingo.odata2.core.ep.producer.AtomEntryEntityProducer.append(AtomEntryEntityProducer.java:99) > at > org.apache.olingo.odata2.core.ep.producer.AtomFeedProducer.appendEntries(AtomFeedProducer.java:143) > at > org.apache.olingo.odata2.core.ep.producer.AtomFeedProducer.append(AtomFeedProducer.java:79) > at > org.apache.olingo.odata2.core.ep.AtomEntityProvider.writeFeed(AtomEntityProvider.java:234) > at > org.apache.olingo.odata2.core.ep.ProviderFacadeImpl.writeFeed(ProviderFacadeImpl.java:122) > at > org.apache.olingo.odata2.api.ep.EntityProvider.writeFeed(EntityProvider.java:513) > at > com.energysys.odata.producer.ResourceEntitySetProcessor.createResponseFeed(ResourceEntitySetProcessor.java:457) > at > com.energysys.odata.producer.ResourceEntitySetProcessor.readEntitySet(ResourceEntitySetProcessor.java:165) > ... > {code} > My entity processor class (ResourceEntitySetProcessor) builds a > Map<String,Object> containing all the required data and invokes the > EntityProvider.writeFeed() method passing the map. > How can I resolve the issue? > Regards -- This message was sent by Atlassian JIRA (v6.2#6252)