问题
I'm currently creating some fixtures for some tests and i faced this error. Have you an idea about how to solve it ?
I've so many fixtures to copy paste it.
A new entity was found through the relationship '***' that was not configured to cascade persist operations for entity:
***. To solve this issue: Either explicitly call EntityManager#persist() on
this unknown entity or configure cascade persist this association in the
mapping for example @OneToOne(..,cascade={"persist"}). If you cannot find
out which entity causes the problem implement '***#__toString()' to get a clue.
回答1:
The error means that there is a related entity in a current object that has not been saved to the database yet. You either need to make sure your relationship is set to cascade persist calls (meaning it will save this automatically) or you need to persist the unsaved entity before saving the current entity.
来源:https://stackoverflow.com/questions/40373891/a-new-entity-was-found-through-the-relationship-that-was-not-configured-to-c