Daniel
Daniel

Reputation: 3514

error thrown on successful saveChanges() call [breezeJS]

I use breeze.angular to communicate with an olingo OData provider. After changing properties of an Entity I have a pending change. The corresponding object is visible when manager.getChanges() is called.

Calling manager.saveChanges in fact results in successful update of the database through olingo. But simultaneously the following error gets thrown:

TypeError: Cannot read property 'entityAspect' of undefined
    at http://localhost:63342/js/breeze.debug.js:14471:38
    at http://localhost:63342js/breeze.debug.js:258:26
    at Array.map (native)
    at __map (http://localhost:63342js/breeze.debug.js:257:15)
    at proto.visitAndMerge (http://localhost:63342/js/breeze.debug.js:14470:16)
    at http://localhost:63342/js/breeze.debug.js:13102:48
    at __using (http://localhost:63342/js/breeze.debug.js:423:16)
    at Object.processSavedEntities (http://localhost:63342/js/breeze.debug.js:13091:13)
    at saveSuccess (http://localhost:63342/js/breeze.debug.js:13070:67)
    at wrappedCallback (http://localhost:63342/js/angular.js:11319:81) 

Apparently breeze is unable to change the entityState, as the objects remain pending changes.

Regarding the http communication I observed two Server requests:

Request Method:OPTIONS
Status Code:200 OK

and

Request Method:POST
Status Code:202 Accepted

Why is breeze unable to transact this succesful update?


UPDATE: Added saveChanges code. (I removed my own logging methods off the callbacks.)

manager.saveChanges()
            .then(saveSucceeded)
            .catch(saveFailed)
            .finally(saveFinal);

        function saveSucceeded(saveResult) {
            console.log(saveResult);
        }

        function saveFinal(saveFinal){
            console.log(saveFinal);
        }

        function saveFailed(error){
            console.log(error);
        }

saveFailed receives the TypeError above, while saveFinal is undefined.

result object:

{  
   "d":{  
      "__metadata":{  
         "id":"http://localhost:8080/targit2/targit2.svc/Applicationlocations(applicationID=2332,locationID=6)",
         "uri":"http://localhost:8080/targit2/targit2.svc/Applicationlocations(applicationID=2332,locationID=6)",
         "type":"targit2.Applicationlocation"
      },
      "applicationID":2332,
      "locationID":6
   }
}

Upvotes: 1

Views: 386

Answers (1)

Steve Schmitt
Steve Schmitt

Reputation: 3219

Breeze uses datajs to convert data to and from the OData formats. I suspect that datajs is having trouble coping with the response from Olingo.

I think Olingo originated with SAP, and this SO post describes a problem with that server.

Upvotes: 1

Related Questions