recommend to use documentManager->getUnitOfWork()->getDocumentId(document) instead of classMetadata->getIdentifierValue(document)