What I did when I've run this issue is write a function which reads the object's metadata dynamically, iterates through them, and copy each field manually.
The metadata will have a property called "fieldNames" with the non-relational fields, and "associationMappings" with the relational ones. An example:
$em = $this->getDoctrine()->getManager();
$objectToClone = $em->getRepository('Xxx')->find(xx);
$class = get_class($objectToClone);
$metadata = $em->getMetadataFactory()->getMetadataFor($class);
// Symfony\Component\PropertyAccess\PropertyAccessor;
$accessor = new PropertyAccessor();
$newObject = new Xxx();
foreach ($metadata->getFieldNames() as $value) {
if (property_exists($objectToClone, $value)) {
$accessor->setValue($newObject, $value, $accessor->getValue($objectToClone, $value));
}
}
foreach ($metadata->getAssociationMappings() as $key => $value) {
if (property_exists($objectToClone, $key)) {
$accessor->setValue($newObject, $key, $accessor->getValue($objectToClone, $key));
}
}
Hope this helps.