I have two entities : an Annonceur can have many Publicite, a Publicite is owned by a single Annonceur :
Annonceur entity :
/**
* @ORMOneToMany(targetEntity=Publicite::class, mappedBy="annonceur", orphanRemoval=true, cascade={"remove"})
* @ORMOrderBy({"id" = "RAND"})
*/
private $publicites;
The OrderBy annotation is used to get Publicite in random order.
Publicite entity :
/**
* @ORMManyToOne(targetEntity=Annonceur::class, inversedBy="publicites")
*/
private $annonceur;
In my controller, when I wan to delete an instance on Annonceur I have this error message :
DoctrineORMPersistersExceptionInvalidOrientation: Invalid order by orientation specified for AppEntityPublicite#id in /home/sami/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/Exception/InvalidOrientation.php:13
Removing the OrderBy annotation fix the problem, but I need to keep it !