DoctrineWriter relational value automatically converting to string
Hi, My English isn't perfect firstly I'm sorry for that.
I have two entity WISPUserAccount and BirdRecord, they are mapped as OneToMany UserAccount has to have a BirdRecord...
Sometimes Writer trying to convert it to a string...
My Bird Record Class
class BirdRecord {
public function __toString() { (string) $this->name; }
}
Data Import Code
$bird = $this->getBird(); // returns BirdRecord object
$userNameFixConverter = new CallbackItemConverter(function ($item) use ($bird) {
$item["bird"] = $bird;
});
$workflow->addItemConverter($userNameFixConverter);
$workflow->setSkipItemOnFailure(true);
$result = $workflow->process();
Error Message:
A new entity was found through the relationship 'Black\Bundle\CustomerBundle\Entity\WISPUserAccount#bird' that was not configured to cascade persist operations for entity: BS-WB-DEV. To solve this issue: Either explicitly call EntityManager#persist() on this unknown entity or configure cascade persist this association in the mapping for example @ManyToOne(..,cascade={"persist"})
I don't know what do you want to archive, but the error message comes from doctrine. It says that you need to add persist to your cascade option.
Here are the link to the docs: http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/working-with-associations.html#transitive-persistence-cascade-operations
I know that the problem I can't bind an object from there if my entity has __toString() method
@Baachi : actually, I don't think cascade is use for TRUNCATE. The second argument of getTruncateTableSQL should be set to true in the doctrine writer.
@Baachi : I was looking for a truncate cascade bug, but this has nothing with this issue sorry. Making a P.R. nonetheless.
@greg0ire No problem, but thank you for your help.
@muratbeser can you create a repo which describe the bug? Maybe it can help to spot the problem.