我在控制台命令中的代码
构造
private $em;
public function __construct(EntityManagerInterface $em, $name = null)
{
parent::__construct($name);
$this->em = $em;
}
...在我的executte命令中始终是OptimisticLockException
protected function execute(InputInterface $input, OutputInterface $output) {
$repository = $this->em->getRepository(ProductData::class);
$product = $repository->findOneBy(array('code' => $data[0]));
$product->setName($data[1]);
$product->setDesc($data[2]);
$product->setStockLevel((float)$data[3]);
$product->setPrice((float)$data[4]);
$this->em->flush(); }
我需要帮助