Skip to Content
Former Member
May 22, 2013 at 03:24 PM

Several questions about ODATA, NavigationProperty and multiple models



I've successfully built the SAP Hana cloud application from this tutorial : and I'm now trying to extend it by adding another features like deletion of a Person (this one is ok) and now Table in my view containing Person's phone(s).

So here are my questions :

What is the best practice when you work with multiple models and different Tables ? I've seen some docs and thread talking about setModel(odataModel, "name"); but I'm not sure how to use this ? It seems like I cannot bind both of my Tables to different models ?

I also have an issue when I'm trying to add a phone.

Here is my $metadata generated from my JPA model

<edmx:Edmx Version="1.0" xmlns:edmx="" xmlns:d="" xmlns:m="">

<edmx:DataServices m:DataServiceVersion =" 1.0 " > <Schema Namespace =" e2e-nwcloud-app-jpa-modelContainer " xmlns="" > <EntityContainer Name =" e2e-nwcloud-app-jpa-modelEntities " m:IsDefaultEntityContainer =" true " > <EntitySet Name =" Phone " EntityType =" e2e-nwcloud-app-jpa-modelModel.Phone " />

<EntitySet Name="Person" EntityType="e2e-nwcloud-app-jpa-modelModel.Person"/>

<AssociationSet Name="FK_Phone_Person" Association="e2e-nwcloud-app-jpa-modelModel.FK_Phone_Person">

<End Role =" Phone " EntitySet =" Phone " />

<End Role="Person" EntitySet="Person"/>

</AssociationSet> </EntityContainer> </Schema>

<Schema Namespace="e2e-nwcloud-app-jpa-modelModel" xmlns="">

<EntityType Name =" Phone " > <Key > <PropertyRef Name =" id " />


<Property Name="id" Type="Edm.Int64" Nullable="true"/>

<Property Name="number" Type="Edm.String" Nullable="true" MaxLength="250"/>

<NavigationProperty Name="person" Relationship="e2e-nwcloud-app-jpa-modelModel.FK_Phone_Person" FromRole="Phone" ToRole="Person"/>


<EntityType Name="Person">

<Key > <PropertyRef Name =" id " />


<Property Name="id" Type="Edm.Int64" Nullable="true"/>

<Property Name="lastName" Type="Edm.String" Nullable="true" MaxLength="250"/>

<Property Name="firstName" Type="Edm.String" Nullable="true" MaxLength="250"/>

<NavigationProperty Name="phones" Relationship="e2e-nwcloud-app-jpa-modelModel.FK_Phone_Person" FromRole="Person" ToRole="Phone"/>


<Association Name="FK_Phone_Person">

<End Role =" Phone " Type =" e2e-nwcloud-app-jpa-modelModel.Phone " Multiplicity =" * " />

<End Role="Person" Type="e2e-nwcloud-app-jpa-modelModel.Person" Multiplicity="0..1"/>

</Association> </Schema> </edmx:DataServices>


My question is how do I POST a Phone "linked" to a Person with json ? I tried specifying a existing person id as it's the foreign key like the code below but with no luck..


//url : _this.odataServiceUrl + "/Person("+id+")/phone?$format=json",

url : _this.odataServiceUrl + "/Phone?$format=json",

type : 'POST',

contentType : 'application/json',

data : JSON.stringify({

number : num,

person_id : personId


Thanks a lot for your help.