I am trying to create an entity that links to existing entities by posting JSON. The issue appears to be with entities having only one-way links between them.
The OfferedDivision entity has a 1:1 link with the Division entity. Simplified Java sources:
@EdmEntityType(namespace = "TEST")
@EdmEntitySet(name = "Divisions")
public class Division {
@EdmKey @EdmProperty(name = "DivisionID")
private String divisionID;
@EdmProperty(name = "Name")
private String name;
// etc.
}
@EdmEntityType(namespace = "TEST")
@EdmEntitySet(name = "OfferedDivisions")
public class OfferedDivision {
@EdmKey @EdmProperty(name = "OfferedDivisionID")
private String offeredDivisionID;
@EdmProperty(name = "OfferDetails")
private String offerDetails;
@EdmNavigationProperty(name = "Division")
private Division division;
// etc.
}
I have posted a Division entity to /Test.svc/Divisions with:
{
"DivisionID": "01",
"Name": "Electricity"
}
I now want to post another entity that links to it, at /Test.svc/OfferedDivisions with:
{
"OfferedDivisionID": "01",
"OfferDetails": "Standard Offer",
"Division": {
"__metadata": {
"uri": "Divisions('01')"
}
}
}
But it doesn't work. The error message includes:
Caused by: org.apache.olingo.odata2.janos.processor.core.util.AnnotationRuntimeException: Missing source field for related data (sourceStore='org.apache.olingo.odata2.janos.processor.core.data.store.InMemoryDataStore@b67a66', targetStore='org.apache.olingo.odata2.janos.processor.core.data.store.InMemoryDataStore@27a933c9').
at org.apache.olingo.odata2.janos.processor.core.data.source.AnnotationDataSource.writeRelation(AnnotationDataSource.java:321)
at org.apache.olingo.odata2.janos.processor.core.DataSourceProcessor.createInlinedEntities(DataSourceProcessor.java:1151)
at org.apache.olingo.odata2.janos.processor.core.DataSourceProcessor.createEntity(DataSourceProcessor.java:324)
I am trying to create an entity that links to existing entities by posting JSON. The issue appears to be with entities having only one-way links between them.
The OfferedDivision entity has a 1:1 link with the Division entity. Simplified Java sources:
I have posted a Division entity to /Test.svc/Divisions with:
{ "DivisionID": "01", "Name": "Electricity" }I now want to post another entity that links to it, at /Test.svc/OfferedDivisions with:
{ "OfferedDivisionID": "01", "OfferDetails": "Standard Offer", "Division": { "__metadata": { "uri": "Divisions('01')" } } }But it doesn't work. The error message includes: