Hi,
I have a strange situation with hydration and unnecessary requests:

I have this schema:
Site  -<>- aRs (actorRsede) -<>- actor




/**
 * MyApp\Database\ActorBundle\Entity\Actor
 *
 * @ORM\Table(name="actor")
* @ORM\Entity(repositoryClass="MyApp\Database\ActorBundle\Entity\ActorRepository")
 * @ORM\InheritanceType("SINGLE_TABLE")
 * @ORM\DiscriminatorColumn(name="actortype", type="string")
 * @ORM\DiscriminatorMap({
 *     "Actor"="MyApp\Database\ActorBundle\Entity\Actor",
 *     "Helpdesk"="MyApp\Database\ActorBundle\Entity\Helpdesk",
 *     "Person"="MyApp\Database\ActorBundle\Entity\Person"
 * })
 *
 */
class Actor
{

/**
  * @ORM\OneToMany(
  *     targetEntity="MyApp\Database\ActorBundle\Entity\ActorRsite",
  *     mappedBy="actor",
  *     cascade={"persist","detach"}
  * )
*/
private $actorRsites;

}






class ActorRsite
{
    /**
     * @var integer $id
     *
     * @ORM\Column(type="integer", name="id")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

/*..string...ruolo che la persona ricotre presso la sede .*/
protected $role;

    /**
* @ORM\ManyToOne(targetEntity="MyApp\Database\ActorBundle\Entity\Actor", inversedBy="actorRsites") * @ORM\JoinColumn(name="actorId", referencedColumnName="id", nullable=false, onDelete="CASCADE") * @Assert\NotBlank( message="Selezionare un Actor o eliminare la riga.")
     */
    protected $actor;


/**
* @ORM\ManyToOne(targetEntity="MyApp\Database\SiteBundle\Entity\Site", inversedBy="actorRsites") * @ORM\JoinColumn(name="site_id", referencedColumnName="id", nullable=false, onDelete="CASCADE")
     */
    protected $site;


}







class Site
{

    /**
     * @ORM\OneToMany(
     * targetEntity="MyApp\Database\ActorBundle\Entity\ActorRsite",
     *     mappedBy="site",
     *     cascade={"persist","detach"}
     * ))
     */
    private $actorRsites;
}




When I run the query:
$query = $em->createQuery('SELECT s FROM MyaAppMyBundle:Site s ')->setMaxResults(20);
just 1 SQL query is ecxecuted... and this is normal! it is OK!

$query = $em->createQuery('SELECT s,aRs FROM MyaAppMyBundle:Site s LEFT JOIN s.actorRsites aRs')->setMaxResults(20);
1 SQL whith JOIN is executed plus 1 SQL foreach aRs to fetch the Actor.
I do not sure this is what I'd like to expect however it is ok.... I should understant....

$query = $em->createQuery('SELECT s,aRs,a FROM MyaAppMyBundle:Site s LEFT JOIN s.actorRsites aRs LEFT JOIN aRs.actor a')->setMaxResults(20); 1 SQL whith JOIN is executed plus 1 SQL foreach aRs to fetch the Actor/Person
I, do not unerstand why?!?
how to optimeize this query?


Thank you in advance,
Oda







--
You received this message because you are subscribed to the Google Groups 
"doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to