private void deleteDocument(@NonNull Document document, @NonNull List<String> partitionKeyNames) { try { final RequestOptions options = new RequestOptions(); Assert.isTrue(partitionKeyNames.size() <= 1, "Only one Partition is supported."); if (!partitionKeyNames.isEmpty() && StringUtils.hasText(partitionKeyNames.get(0))) { options.setPartitionKey(new PartitionKey(document.get(partitionKeyNames.get(0)))); } getDocumentClient().deleteDocument(document.getSelfLink(), options); } catch (DocumentClientException e) { throw new DocumentDBAccessException("Failed to delete document: " + document.getSelfLink(), e); } }
protected <R extends Object> R readInternal(final DocumentDbPersistentEntity<?> entity, Class<R> type, final Document sourceDocument) { final R result = instantiate(type); final PersistentPropertyAccessor accessor = entity.getPropertyAccessor(result); final DocumentDbPersistentProperty idProperty = entity.getIdProperty(); final Object idValue = sourceDocument.getId(); if (idProperty != null) { accessor.setProperty(idProperty, idValue); } entity.doWithProperties((PropertyHandler<DocumentDbPersistentProperty>) prop -> { if (idProperty != null && idProperty.equals(prop)) { return; } accessor.setProperty(prop, sourceDocument.get(prop.getName())); } ); return result; }