Open GregoireTenor opened 5 years ago
How are the metadata for the Country
class?
Both doctrine and jms
/**
* @ORM\Entity()
*/
class Country
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=2)
* @Serializer\Type("string")
*/
private $code;
/**
* @ORM\Column(type="string", length=50, nullable=true)
* @Serializer\Type("string")
*/
private $name;
public function getId(): ?int
{
return $this->id;
}
public function getCode(): ?string
{
return $this->code;
}
public function setCode(string $code): self
{
$this->code = $code;
return $this;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(?string $name): self
{
$this->name = $name;
return $this;
}
}
Why did you add the "question" label ? It's a bug ! Did you reproduce it ?
The primary key in your entity is "id", but you are sending the "code" in the xml data
JMS serializer detects it as doctrine entity and tries to load it
JMS should work without the id for new entities to persist... It works in Symfony 2... But you think it's normal ?
could be related to https://github.com/schmittjoh/serializer/pull/951
Can you check if adding jms/serializer: 1.11.*
works?
I added jms/serializer: 1.11.*, but it doesn't work either
Hi,
We have this exception when we deserialize XML in Symfony 4 :
Doctrine\ORM\EntityNotFoundException: "Entity of type 'xxx' for IDs id() was not found"
This is our code :
The same code works in Symfony 2 project.
This is my configuration :
Thanks for your help