0

使用cars-jpa-archetype示例,我可以在 XML 中执行深度插入(汽车和驾驶员),但不能在 JSON 中执行。在下面使用我的 JSON 1 或 2 时,只插入了 Car 并且 Driver 为空。任何人都可以阐明我的 JSON 输入吗?如果我使用 Olingo 注释(@EdmEntityType 等),则 JSON 输入没有问题。

<?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"
        }
      }
    }
  }
}

很抱歉在这里发帖,因为 Olingo 论坛没有回应。

4

1 回答 1

-1

似乎在他们的 Jira 上发布了同样的问题,但现在应该已经解决了: https ://issues.apache.org/jira/browse/OLINGO-515

于 2015-11-03T12:11:46.193 回答