[ 
https://issues.apache.org/jira/browse/OLINGO-459?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14176040#comment-14176040
 ] 

Chandan V.A commented on OLINGO-459:
------------------------------------

Hello [~chrisam],  [~mirbo]
While analyzing the execution of $batch calls with $links I could observe a 
certain behavior in the library. The behavior is that, for the entire execution 
of a $batch call only one instance of OData Processor is instantiated and 
initialized only once with the OData Context. The initialized OData Context has 
a Path Info of $batch request. For example consider the below $batch call 
(http://localhost:8080/olingo-odata2-jpa-processor-ref-web/SalesOrderProcessing.svc/$batch)
 - for creating a Customer Entity and linking it with an Existing Sales Order.

--batch_123
Content-Type: multipart/mixed; boundary=changeset_321
   
--changeset_321
Content-Type: application/http
Content-Transfer-Encoding: binary

POST Customers HTTP/1.1
Content-Length: 32
DataServiceVersion: 1.0
Content-Type: application/json;odata=verbose
MaxDataServiceVersion: 2.0

{"Id":"1001","Name":"Bob Bryan"}

--changeset_321
Content-Type: application/http
Content-Transfer-Encoding: binary

POST Customers(1001L)/$links/SalesOrderDetails HTTP/1.1
DataServiceVersion: 2.0
Content-Type: application/xml
MaxDataServiceVersion: 2.0
Content-Length:  211

<?xml version="1.0" encoding="UTF-8"?>
<uri 
xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices";>http://localhost:8080/olingo-odata2-jpa-processor-ref-web/SalesOrderProcessing.svc/SalesOrders(2L)</uri>
--changeset_321--

--batch_123--

When the above call is executed following steps are performed
1) An OData Single Processor (in this case JPA processor) is instantiated and 
initialized with an OData Context. The OData Context has a path Info (with 
OData Segments) pointing to the $batch request. Example - 
http://localhost:8080/olingo-odata2-jpa-processor-ref-web/SalesOrderProcessing.svc/$batch
2) The call is next delegated to the appropriate method of Single Processor for 
execution. In this case say createEntityLink.
3) The method createEntityLink needs the Path Info about the $link URL. Example 
- Customers(1001L)/$links/SalesOrderDetails. Using Path Info a custom UriInfo 
object is constructed for the URL Customers(1001L) and used for querying the 
Customer Entity from DB.
4) Since the processor is reused across all operations of a $batch call with 
same OData Context, createEntityLink gets the Path Info as 
http://localhost:8080/olingo-odata2-jpa-processor-ref-web/SalesOrderProcessing.svc/$batch
 from OData Context instead of Customers(1001L)/$links/SalesOrderDetails.

Because of the above step the $link calls fail within $batch.

Can you please check whether we need to pass OData Contexts initialized with 
the Path Info pointing to each HTTP operation within $batch call.

Thanks
Kind Regards
Chandan

> JPA Batch does not support creating new instance and link this to an existing 
> one in one change set
> ---------------------------------------------------------------------------------------------------
>
>                 Key: OLINGO-459
>                 URL: https://issues.apache.org/jira/browse/OLINGO-459
>             Project: Olingo
>          Issue Type: Bug
>          Components: odata2-jpa
>    Affects Versions: V2 2.0.0
>            Reporter: Björn Wagner
>            Assignee: Chandan V.A
>
> Steps necessary to reproduce this:
> (1) Create new instance (including client generated GUID primary key)
> (2) Link this instance to another already existing instance of a different 
> entity
> While the exact same requests work fine when executed as single requests, the 
> second one fails when executed in batch. I debugged into the olingo code and 
> the exception is thrown at 
> org.apache.olingo.odata2.jpa.processor.core.access.data.JPALink:276
> It looks like the wrong UriInfo is passed into that function. At first 
> glance, this function receives the UriInfo from the outer batch request 
> instead of the info for the link request. 



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

Reply via email to