@Override
public void removeAssociation(AssociationKey key, AssociationContext associationContext) {
if ( isStoredInEntityStructure( key.getMetadata(), associationContext.getAssociationTypeContext() ) ) {
EntityDocument owningEntity = getDataStore().getEntity( Identifier.createEntityId( key.getEntityKey() ) );
if ( owningEntity != null ) {
owningEntity.removeAssociation( key.getMetadata().getCollectionRole() );
getDataStore().saveDocument( owningEntity );
}
}
else {
removeDocumentIfPresent( Identifier.createAssociationId( key ) );