Annotation @OrderBy

Lughino picture Lughino · Aug 12, 2013 · Viewed 13.8k times · Source

I'm trying to automatically order the results of a report by the ManyToMany annotation @OrderBy:

/**
 * @ORM\ManyToMany(targetEntity="Artist", inversedBy="soundtrack", cascade={"persist", "remove"})
 * @ORM\JoinTable(name="soundtrack_artist")
 * @OrderBy({"name" = "ASC", "surname" = "ASC"})
 **/
private $artists;

but it gives me this error:

[Semantical Error] The annotation "@OrderBy" in property
Acme\UserBundle\Entity\Soundtrack::$artists was never imported.
Did you maybe forget to add a "use" statement for this annotation?

I tried to add also:

use Doctrine\ORM\Mapping\OrderBy;

But the error remains! I'm doing something wrong?

Answer

Prasad picture Prasad · Aug 2, 2014

Not sure if you found the answer, but this worked for me:

@ORM\OrderBy