diff --git a/platform/core/src/capabilities/PersistenceCapability.js b/platform/core/src/capabilities/PersistenceCapability.js index 186205aeb0..35fd6d8de1 100644 --- a/platform/core/src/capabilities/PersistenceCapability.js +++ b/platform/core/src/capabilities/PersistenceCapability.js @@ -202,6 +202,15 @@ define( return this.identifierService.parse(id).getSpace(); }; + /** + * Check if this domain object has been persisted at some + * point. + * @returns {boolean} true if the object has been persisted + */ + PersistenceCapability.prototype.persisted = function () { + return this.domainObject.getModel().persisted !== undefined; + }; + return PersistenceCapability; } ); diff --git a/platform/core/src/runs/PersistingMutationListener.js b/platform/core/src/runs/PersistingMutationListener.js index 54df8b4e56..c41934df02 100644 --- a/platform/core/src/runs/PersistingMutationListener.js +++ b/platform/core/src/runs/PersistingMutationListener.js @@ -34,7 +34,9 @@ define([], function () { var mutationTopic = topic('mutation'); mutationTopic.listen(function (domainObject) { var persistence = domainObject.getCapability('persistence'); - persistence.persist(); + if (persistence.persisted()) { + persistence.persist(); + } }); }