简体   繁体   English

JSON中的Olingo 2 OData JPA深度插入

[英]Olingo 2 OData JPA Deep Insert in JSON

With cars-jpa-archetype example, I am able to perform deep insert (Car and Driver) in XML but not JSON. 通过cars-jpa-archetype示例,我能够以XML而不是JSON进行深度插入(Car和Driver)。 With my JSON 1 or 2 at below, only Car is inserted and Driver is null. 使用下面的JSON 1或2,仅插入Car,而Driver为null。 Any one can shed light on my JSON inputs? 任何人都可以了解我的JSON输入吗? Have no issue with JSON input if I use Olingo annotations (@EdmEntityType etc). 如果我使用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"
        }
      }
    }
  }
}

Sorry for cross post here as no response from the Olingo forum. 很抱歉在这里发表交叉帖子因为Olingo论坛没有回复。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM