When to use modelService.refresh() method?

The OOB Hybris Model Service provides a method, to refresh the model. Usually we use this method to refresh the data, before saving the data in database, using save method.

There might be conditions, where some other thread or operation would be updating the same model instance. Br doing a refresh, we can be sure of not loosing those changes. This is of more importance, if we are going through a time consuming transaction like payment.

refresh model


Also transaction like, stock update, may happen simultaneously from multiple users, so we should always refresh the model, before saving it.