Search code examples
odatasapui5crudput

SAPUI5 oData PUT operation requires GET ENTITY implementation


I implemented the update operation for an oData service. When I tried to call it via my SAPUI5 application, I got the following error message:

'XXX_GET_ENTITY' not implemented in data provider class

That's true - I did not yet implement the GET ENTITY method. However, can someone tell me why I need this one for an update?

The JS coding for the service request is created this way:

oDataModel.update("/EntitySetName(<key>)", oPayload, {
   success: function(oData) {
      ...
   },
   error: function(oError) {
      ...
   }
});

I appreciate every hint / explanation.


Solution

  • The default update method for the ODataModel is a patch/merge, see the documentation from the ODataModel class:

    Trigger a PUT/MERGE request to the OData service that was specified in the model constructor.

    The update method used is defined by the global defaultUpdateMethod parameter which is sap.ui.model.odata.UpdateMethod.Merge by default. [...]

    The default implementation of the PATCH_ENTITY method calls the READ_ENTITY first and then merges the incoming data with the retrieved data to allow for partial updates. From the comments in this method:

    *-a patch request is a partial update of an entity. All provided components are patched.
    *-The default implementation of patch_entity performs a read before update [...]
    

    To do a PUT request, set the updateMethod property to sap.ui.model.odata.UpdateMethod.Put.