Mahdi Ansari created OLINGO-1464:
------------------------------------
Summary: Batch with multiple change sets does not work,
Key: OLINGO-1464
URL: https://issues.apache.org/jira/browse/OLINGO-1464
Project: Olingo
Issue Type: Question
Components: odata2-jpa
Affects Versions: V2 2.0.11
Reporter: Mahdi Ansari
You can see a full report regarding the olingo jpa problem with batches that
have more than one changeset.
[https://github.com/jpenninkhof/odata-boilerplate/issues/1]
As soon as you have multiple change sets you will see the following error:
{code:java}
<?xml version='1.0' encoding='UTF-8'?><error
xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<code/> <message xml:lang="en">Error on processing request content:Cannot
begin Transaction on closed Session/EntityManager</message></error>
{code}
The problems is coming from 2 lines that I commented them out as following:
{code:java}
@Override
public BatchResponsePart executeChangeSet(final BatchHandler handler, final
List<ODataRequest> requests)
throws ODataException {
List<ODataResponse> responses = new ArrayList<ODataResponse>();
try {
//oDataJPAContext.getODataJPATransaction().begin();
for (ODataRequest request : requests) {
oDataJPAContext.setODataContext(getContext());
ODataResponse response = handler.handleRequest(request);
if (response.getStatus().getStatusCode() >=
HttpStatusCodes.BAD_REQUEST.getStatusCode()) {
// Roll Back
oDataJPAContext.getODataJPATransaction().rollback();
List<ODataResponse> errorResponses = new ArrayList<ODataResponse>(1);
errorResponses.add(response);
return
BatchResponsePart.responses(errorResponses).changeSet(false).build();
}
responses.add(response);
}
//oDataJPAContext.getODataJPATransaction().commit();
return BatchResponsePart.responses(responses).changeSet(true).build();
} catch (Exception e) {
throw new ODataException("Error on processing request content:" +
e.getMessage(), e);
} finally {
close(true);
}
}{code}
It does not need to `commit` after each changeset!
--
This message was sent by Atlassian Jira
(v8.3.4#803005)