'How save an ID in relationship field - symfony

My field in the entity client:

/**
 * @ORM\ManyToOne(targetEntity="App\Entity\ClientRestrictiveListValidationType")
 * @ORM\JoinColumn(name="id_type_validation")
 */
private $validationType;

to save I must do the following:

$validationType = $this->entityManager->getRepository(ValidationType::class)->find($idValidationType);
$client->setValidationType($validationType);

but when looking for the type of validation, I am doing an extra query. If I already have the $idValidationType I want to save, I don't want to do an extra query.

The entity is old and the properties is used for other services, for that I can't change the properties



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source