Hi,
I've successfully built the SAP Hana cloud application from this tutorial : http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/a0a7e630-2415-3010-57aa-cb1ad288780f?QuickLink=index&overridelayout=true&57655641068742 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="http://schemas.microsoft.com/ado/2007/06/edmx" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<edmx:DataServices m:DataServiceVersion =" 1.0 " > <Schema Namespace =" e2e-nwcloud-app-jpa-modelContainer " xmlns="http://schemas.microsoft.com/ado/2006/04/edm" > <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="http://schemas.microsoft.com/ado/2006/04/edm">
<EntityType Name =" Phone " > <Key > <PropertyRef Name =" id " /> </Key><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><EntityType Name="Person">
<Key > <PropertyRef Name =" id " /> </Key><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"/>
</EntityType><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></edmx:Edmx>
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..
jQuery.ajax({
//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.
Regards