You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@olingo.apache.org by "Michael Bolz (JIRA)" <ji...@apache.org> on 2015/02/13 14:53:13 UTC

[jira] [Updated] (OLINGO-574) Batch request inserting master/detail entities not working

     [ https://issues.apache.org/jira/browse/OLINGO-574?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Michael Bolz updated OLINGO-574:
--------------------------------
    Issue Type: New Feature  (was: Bug)

> Batch request inserting master/detail entities not working
> ----------------------------------------------------------
>
>                 Key: OLINGO-574
>                 URL: https://issues.apache.org/jira/browse/OLINGO-574
>             Project: Olingo
>          Issue Type: New Feature
>          Components: odata2-jpa
>    Affects Versions: V2 2.0.1
>         Environment: JPA (Hibernate), MacOS, tomcat 7, Oracle 12c database
>            Reporter: Ivan Lucas Vargas
>            Assignee: Michael Bolz
>
> According to the OData specification, we can relate post requests for inserting entities in the same batch request: http://www.odata.org/documentation/odata-version-2-0/batch-processing (item 2.2.1 - Referencing requests in a changeset)
> Olingo should understand the master / detail relationship as per metadata navigation properties and:
> 1. Insert the master entity and get the sequence Id of it (as per JPA mapping)
> 2. Before inserting the details entities, it should update this entities by setting the master id into the details entities, and then persist to respect the fk relationship
> When sending the request, Olingo does not understand this relationship and does not update the details entities with the Id of the master entity.
> Details:
> I'm trying to insert one entity with a list of another entity in the same batch request. In my case, the post payload is:
> --batch_98b2-5d17-73e4
> Content-Type: multipart/mixed; boundary=changeset_3d94-0d7a-375d
> --changeset_3d94-0d7a-375d
> Content-Type: application/http
> Content-Transfer-Encoding: binary
> POST Orders HTTP/1.1
> Content-ID: 1
> DataServiceVersion: 2.0
> Accept: application/atomsvc+xml;q=0.8, application/json;odata=fullmetadata;q=0.7, application/json;q=0.5, */*;q=0.1
> Content-Type: application/json
> MaxDataServiceVersion: 3.0
> {"OrderId":-1,"Customer":1}
> --changeset_3d94-0d7a-375d
> Content-Type: application/http
> Content-Transfer-Encoding: binary
> POST OrderItems HTTP/1.1
> Content-ID: 2
> DataServiceVersion: 2.0
> Accept: application/atomsvc+xml;q=0.8, application/json;odata=fullmetadata;q=0.7, application/json;q=0.5, */*;q=0.1
> Content-Type: application/json
> MaxDataServiceVersion: 3.0
> {"OrdemItemId":-2,"OrderId":-1,"ProductId":132}
> --changeset_3d94-0d7a-375d--
> --batch_98b2-5d17-73e4--
> The idea here is to insert both entities. So, we have the OrderId: -1 and OrderItemId: -2. This way, olingo will understand and generate the ids based on the Oracle sequence mapped into the JPA entities. But, as far as I read till now, the second changeset should reference the first changeset, by using the $ in the POST. So, it should be:
> POST OrderItems HTTP/1.1 (original) -> POST $1/OrderItems HTTP/1.1 (by referencing the content-id: 1 of the first changeset)
> Is this understanding correct? If yes, the second question is: My payload needs to have the navigation link included? In this case, the payload sould be something like:
> {"OrdemItemId":-2,"OrderId":-1,"ProductId":132} (original) -> {"OrdemItemId":-2,"OrderId":-1,"ProductId":132, OrderDetails: {url: __deferred}}
> Is this understand also correct? Or by the navigation link olingo will understand that in the entity OrderItem, the property OrderId is a property link and will resolve this referenced request and will fill the attribute OrderItem.OrderId with the Order.OrderId that was already updated with the sequence value got from the entity resolution of the first changeset?
> The navigation property for this relationship generated by the $metadata is:
> <NavigationProperty Name="OrderDetails" Relationship="pu.Order_OrderItem" FromRole="OrderItem" ToRole="Order"/>



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)