diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirDao.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirDao.java index 7b7bd441049..e5eca6dee30 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirDao.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirDao.java @@ -1482,6 +1482,15 @@ public abstract class BaseHapiFhirDao implements IDao, // nothing } + /** + * Subclasses may override to provide behaviour. Called when a pre-existing resource has been updated in the database + * + * @param theEntity The resource + */ + protected void postDelete(ResourceTable theEntity) { + // nothing + } + /** * Subclasses may override to provide behaviour. Called when a pre-existing resource has been updated in the database * @@ -2027,6 +2036,10 @@ public abstract class BaseHapiFhirDao implements IDao, postPersist(theEntity, (T) theResource); + } else if (theEntity.getDeleted() != null) { + + postDelete(theEntity); + } else { theEntity = myEntityManager.merge(theEntity);