Olingo 2 OData JPA Deep Insert in JSON

1.4k views Asked by At

With cars-jpa-archetype example, I am able to perform deep insert (Car and Driver) in XML but not JSON. With my JSON 1 or 2 at below, only Car is inserted and Driver is null. Any one can shed light on my JSON inputs? Have no issue with JSON input if I use Olingo annotations (@EdmEntityType etc).

<?xml version="1.0" encoding="UTF-8"?>
<entry xmlns="http://www.w3.org/2005/Atom" xmlns:d="
http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="
http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xml:base="
http://localhost:8080/example/MyFormula.svc/">
   <category term="MyFormula.Car" scheme="
http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
   <link href="Cars(Id=553,IdL=554L)" rel="edit" title="Car" />
   <link href="Cars(Id=553,IdL=554L)/DriverDetails" rel="
http://schemas.microsoft.com/ado/2007/08/dataservices/related/DriverDetails"
title="DriverDetails" type="application/atom+xml;type=entry">
      <m:inline>
         <entry xml:base="http://localhost:8080/example/MyFormula.svc/">
            <category term="MyFormula.Driver" scheme="
http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
            <link href="Drivers(10L)" rel="edit" title="Driver" />
            <link href="Drivers(10L)/CarDetails" rel="
http://schemas.microsoft.com/ado/2007/08/dataservices/related/CarDetails"
title="CarDetails" type="application/atom+xml;type=entry" />
            <content type="application/xml">
               <m:properties>
                  <d:Birthday>2014-12-05T14:35:11.141</d:Birthday>
                  <d:Id>10</d:Id>
                  <d:Lastname>Super</d:Lastname>
                  <d:Name>Speeder</d:Name>
                  <d:Nickname>TN</d:Nickname>
               </m:properties>
            </content>
         </entry>
      </m:inline>
   </link>
   <content type="application/xml">
      <m:properties>
         <d:Id>553</d:Id>
         <d:IdL>554</d:IdL>
         <d:Model>M1</d:Model>
         <d:ModelYear>2014</d:ModelYear>
         <d:Price>20000.0</d:Price>
         <d:Updated>2014-03-20T14:35:17.075</d:Updated>
      </m:properties>
   </content>
</entry>

// JSON 1

{
  "Id":677,
  "IdL":"678",
  "Model":"M1",
  "ModelYear":2014,
  "Price":"20000.0",
  "Updated":"\/Date(1395326117075)\/",
  "DriverDetails":{
    "Birthday":"\/Date(1417790111141)\/",
    "Id":"3",
    "Lastname":"Super",
    "Name":"Speeder",
    "Nickname":"YZ",
    "CarDetails": {
      "__deferred": {
        "uri": "
http://localhost:8080/example/MyFormula.svc/Drivers(3)/CarDetails"
      }
    }
  }
}

// JSON 2

{
  "d": {
    "__metadata": {
      "type": "MyFormula.Car"
    },
    "Id": 601,
    "IdL": "602",
    "Model": "M1",
    "ModelYear": 2014,
    "Price": "20000.0",
    "Updated": "/Date(1395244800000)/",
    "DriverDetails": {
      "__metadata": {
        "id": "http://localhost:8080/example/MyFormula.svc/Drivers(11L)",
        "uri": "http://localhost:8080/example/MyFormula.svc/Drivers(11L)",
        "type": "MyFormula.Driver"
      },
      "Birthday": "/Date(1417795200000)/",
      "Id": "11",
      "Lastname": "Super",
      "Name": "Speeder",
      "Nickname": "Bolt",
      "CarDetails": {
        "__deferred": {
          "uri": "
http://localhost:8080/example/MyFormula.svc/Drivers(11L)/CarDetails"
        }
      }
    }
  }
}

Sorry for cross post here as no response from the Olingo forum.

1

There are 1 answers

0
Nishant Chellani On BEST ANSWER

Seems like the same issue was posted on their Jira but it should have been resolved now: https://issues.apache.org/jira/browse/OLINGO-515